I need a little help manipulating the output of the following code
$OUlists = get-adgroupmember -identity "Test-group" | select -ExpandProperty distinguishedname | sort distinguishedname
$OUlists.Trimstart("OU")
the output of the script returns the full distinguished name of the systems and I need to drop everything before the first occurrence of “OU”
for example, the output is CN=Test,OU=TestOU,OU=TestOU2,DC=Test,DC=Test1,DC=Test2,DC=Test3,DC=Test4
I need the output to be OU=TestOU,OU=TestOU2,DC=Test,DC=Test1,DC=Test2,DC=Test3,DC=Test4
I have tried Trim, TrimStart, SPlit, substing and i cant manipulate my sting the way i need it to be.
one of the issues I encountered is that the character length in CN=Test varies depending on the computer name so i cant trim based on character count
I know its something simple I am overlooking and hoping someone can assist and point out my error.
thank you for your help in advance