PowerShell 2.0 Regex Distinguished Names.

Looking for a way to parse a string that contains multiple Distinguished Names to put the names into a separate array.
Example.

$String = "CN=John S. Smith*a,OU=Users,OU=Tier 8,OU=Admins,DC=fg,DC=ef,DC=na,DC=ORG CN=Joe D. Smith*a,OU=Users,OU=Tier 2,OU=Admins,DC=fd,DC=hd,DC=tv,DC=ORG"

to

$NewString ="CN=John S. Smith*a,OU=Users,OU=Tier 8,OU=Admins,DC=fg,DC=ef,DC=na,DC=ORG"
"CN=Joe D. Smith*a,OU=Users,OU=Tier 2,OU=Admins,DC=fd,DC=hd,DC=tv,DC=ORG"
Xytras1Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
footechConnect With a Mentor Commented:
Try this.
$NewString = $String -split "CN=" | ? {$_} | % {"CN=$($_.trim())"}

Open in new window

0
 
Xytras1Author Commented:
Works great. Thank you.
0
All Courses

From novice to tech pro — start learning today.