Solved

PowerShell 2.0 Regex Distinguished Names.

Posted on 2014-11-05
2
319 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DNS logs 1 33
I'm being stupid with my powershell 2 29
Windows7 without Drivers fresh install 19 50
Backup Software for Windows 7 9 68
A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

710 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