Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Regular expression

$
0
0

Hello,

I need to split a string (a Distinguished Name) in 2 parts: CN and OUs

Here is an example of the string:

$DNString = "CN=MyGroup,OU=OU3,OU=OU2,OU=OU1,DC=mydomain,DC=local"

With this command, I can get CN part:

$CN = $DNString.Split(",") | select -first 1

But I fail to get OU part: OU=OU3,OU=OU2,OU=OU1

What would be your advice ? Using regular expressions, a Select-String or something else ?
Thanks for your help !

Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>