Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Leverage the power of RegEx!
# 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
You can’t perform that action at this time.