Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

RegEx Hell

$
0
0

I have a report of AD linked values where i want to output just lines that start with LEGACY and the DN that follows. 

The following is a text snipet of the report I want to load from a file and sample code:

$imputfile = "PRESENT       member 2015-10-24 15:47:54   3fddf2e6-de67-407b-aa8c-65b8024cad30   83428  146532   2

 

        CN=White\,Dora,OU=US,OU=UserAccounts,DC=tailspin,DC=dev

 

LEGACY        member

 

        CN=Buck\,Bernard,OU=US,OU=UserAccounts,DC=tailspin,DC=dev"

$pattern='(LEGACY\s+member)\W+(cn=\S*DC\=tailspin\,DC\=dev)'
[string]$inputfile | Select-String $pattern -Context 3
Can someone tell me what I'm doing wrong? It seemed like a simple task to return just the legacy members but i keep getting the whole string. 

Viewing all articles
Browse latest Browse all 6937

Trending Articles