Solved

PowerShell 2.0 Regex Distinguished Names.

Posted on 2014-11-05
2
308 Views
Last Modified: 2014-11-05
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"
0
Comment
Question by:Xytras1
2 Comments
 
LVL 39

Accepted Solution

by:
footech earned 500 total points
ID: 40425002
Try this.
$NewString = $String -split "CN=" | ? {$_} | % {"CN=$($_.trim())"}

Open in new window

0
 

Author Closing Comment

by:Xytras1
ID: 40425011
Works great. Thank you.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick guide on how to use Group Policy to create a custom power plan and set it active on Windows 7.
A brief introduction to what I consider to be the best editor for PowerShell.
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will give you a basic overview of Windows Live Photo Gallery and show you various editing filters and touches to photos you can apply. This will be demonstrated using Windows Live Photo Gallery on Windows 7 operating system.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question