Added validation of the destination shadow group and OU to ensure it can be created

Hi Dave,

Please take a look and let me know what you think. Have tried to follow style of the rest of the script. The RegEx is not great but couldn't find a better way to get the OU of a distinguished name...

Ian.
Thanks, that's awesome!

You could always return the parent OU of the group by getting it as a directoryentry object which exposes more information.

Replacing the regular expression with ([string]([ADSI]"LDAP://$adgroup").PSBase.Parent.distinguishedName) will do what you are looking for, however the regular expression is faster, unless we get the directoryentry earlier, as $adGroup, then work from there.

Whichever is fine by me, just let me know and I'll merge whichever solution you prefer.