How can I use Regex to pull just the CN from a Distinguished Name with PowerShell

后端 未结 6 1827
礼貌的吻别
礼貌的吻别 2020-12-11 21:04

I have a bunch of strings that are DN\'s of groups from AD. I need to pull out the Common Name. An example string is \"CN=Group Name I Want,OU=Group Container,DC=corp,DC=tes

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-11 21:51

    $s = "CN=Group Name I Want,OU=Group Container,DC=corp,DC=test,DC=local"
    $s1 = ($s -split ",*..=")[1]
    $s1
    

提交回复
热议问题