Hi,
I am new to Powershell but have a requirement to copy the groups that one user is a member of to another user's Active directory account.
Unfortunately we do not use and Quest Snap-ins due to current company policy so can only use the PS v2 cmdlets.
I saw this PS script but not sure how to use it
$user1 = [ADSI]"LDAP://CN=from,OU=Test,DC=Contoso,DC=com"
$user2 = [ADSI]"LDAP://CN=to,OU=Test,DC=Contoso,DC=com"
foreach ($group in $user1.memberof)
{
Here is my version of the script which fails as I am obviously doing something wrong :(
$user1 = [ADSI]"LDAP://CN=Testuser1,OU=Test Users,OU=Test,OU=TestLab,DC=Lab.Net"
$user2 = [ADSI]"LDAP://CN=Testuser2,OU=Staging,DC=Lab.Net
foreach ($group in $user1.memberof)
{
$group = [ADSI]"LDAP://$group"
$DN = $user2.distinguishedName
$group.Add("LDAP://$DN")
}
Thanks for any help with this