tag:blogger.com,1999:blog-62687483129304921.post6245986361194390405..comments2024-03-28T13:13:53.318+01:00Comments on ADdict: ADMT: OU syntax in Option File or vbScriptThomashttp://www.blogger.com/profile/12651864373303201993noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-62687483129304921.post-31112312764765686712012-08-15T02:20:51.178+02:002012-08-15T02:20:51.178+02:00In case someone needs to do this and doesn't w...In case someone needs to do this and doesn't wanna take the time to roll their own. I whipped this up for this little task. <br /><br /># Target OU must be in slash format and not have any of the DC portion.<br />$targetOU -match "^(.*?),DC.*$"<br /><br />$s = $matches[1].ToLower() <br /><br />$s = $s.replace(',cn=','/').replace('cn=','').replace(',ou=','/').replace('ou=','')<br /> <br /># Now split by / to make tokens<br />$tokens = $s.split('/') <br /><br />[array]::Reverse($tokens)<br /><br />$slashOU = $null<br /><br /># Put back together again..<br />foreach ($token in $tokens){<br /> $slashOU += ($token + "/")<br />}<br /> <br /># Kill trailing slash<br />$slashOU = $slashOU.Substring(0, $slashOU.length - 1)Matt D.https://www.blogger.com/profile/06547248866368589105noreply@blogger.com