Skip to content

Instantly share code, notes, and snippets.

@rodmhgl
Created October 22, 2013 16:13
Show Gist options
  • Save rodmhgl/7103540 to your computer and use it in GitHub Desktop.
Save rodmhgl/7103540 to your computer and use it in GitHub Desktop.
Regex, extract DC from DN
$DN = 'CN=Username,OU=OrganizationalUnit,DC=lab,DC=local'
$pattern = '(?i)DC=\w{1,}?\b'
([RegEx]::Matches($DN, $pattern) | ForEach-Object { $_.Value }) -join ','
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment