parsing - Parse GUID out of string -
i running issue following using trim. removing of guid. guid out of this. if appreciative.thank in advanced.
((get-adorganizationalunit -filter {name -eq "ouname"} -properties linkedgrouppolicyobjects,gplink) | foreach-object {if($_.gplink){$_.gplink.split(",") | foreach-object {if($_ -like 'dc=dcname*'){if($_.length -gt 10){(((($_).trim('dc=dcname;0][ldap://cn={')).trim('}')) ) }} }}})
my output this:
754ff9f1-078a-4e05-913d-4f36572b2fc6 eddaab18-2ba6-42e6-a5ec-21b0227be71a 7df312db-eb73-418e-8f64-3e391f4639b7 6e3512-4100-48a3-9a65-4da17a0e2d87 72ef89d6-2c57-40ac-a116-2cad89f453ed 2][ldap://cn={31bb7749-f6dc-4098-8f10-9d8b4b0f0c0a 78528b0-f379-4e8f-a166-ace1448af9b2
without input cannot sure, might try this
get-adorganizationalunit -filter {name -eq 'ouname'} -properties linkedgrouppolicyobjects, gplink | foreach-object { if ($_.gplink) { $_.gplink.split(',') | foreach-object { if ($_ -like 'dc=dcname*' -and $_.length -gt 10) { #$_ = $_ -replace 'dc=dcname;\d+\]\[ldap:\/\/cn=\{' #$_.trim('}') $_ -replace '^.*([a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}).*$', '$1' } } } }
Comments
Post a Comment