Powershell scriipt for mirror user accounts group membership


I have created small power shell script where we can use this for mirror active directory user group membership. This script is usefulll when the new user coming to the organization we should give the correct group membership.




Write-Host “Please enter the user name of the source user”

Write-Host “Please type the user name which you want to mirror”


$strgmem=Get-ADPrincipalGroupMembership $strsourceuser

for($a=0; $a -le (($strgmem).Count)-1;$a++)

Write-Host $strgmem[$a].name

Add-ADGroupMember $grpname -Members $struser -ErrorAction SilentlyContinue