Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Split CanonicalName/Identity

$
0
0

Hi,

I have been trying to figure out how to split (or delimit) the [Identity] or [CN] variable of a active directory user object at a certain point but then only return the objects before that point.

This is problematic because a CN contains the same delimiter, "/". So essentially I'm trying to delimit on a specific occurrence of a character.

For example :
$string="contoso.local/Country/City/Office/Resources/Users/User1"

I want to return everything before the 4th "/" :
"contoso.local/Country/City/Office"

I can use 'split' to return "/Resources/Users/User1" but I can't figure out how to retrieve the data preceding.

Can anyone clue me in please??

Thanks


Viewing all articles
Browse latest Browse all 6937

Trending Articles