I'm attempting to remove everything after and including the last slash in a CanonicalName. As you might expect that amount of letters, characters, words and the length are variable. Which is why I need to use the fact that everything after the last slash "/" is the only thing each one has in common.
I'm using the following:
(Get-ADUser Identity USER -Properties *).CanonicalName
Normal output would be something like:
domain.tld/dept/section/office/USER
What I would like the result to be is:
domain.tld/dept/section/office
Eventually this will be incorporated into for loop and run through thousands of users which is why I need to find a way to strip off the end.