Created
December 22, 2014 17:08
-
-
Save IISResetMe/69453fcef29419a79e8a to your computer and use it in GitHub Desktop.
Leverage the power of RegEx!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Negative lookbehind | |
function Split-DN{ | |
param([String]$DN) | |
return $DN-split"(?<!\\)," | |
} | |
# Positive lookbehind with negative expression | |
function Split-DN{ | |
param([String]$DN) | |
return $DN-split"(?<=[^\\])," | |
} | |
# Usage: | |
Split-DN -DN "CN=User\, A Friendly,OU=Idiotas,DC=domain,DC=tld" | |
# Returns an ordered array containing each component in the DN: @("CN=User\, A Friendly","OU=Idiotas","DC=domain","DC=tld") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment