Created
April 27, 2012 07:07
-
-
Save weipah/2506769 to your computer and use it in GitHub Desktop.
Copy ActiveDirectory-Groups from one user to another
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function XADGroupCopy() { | |
param( | |
[parameter(Mandatory=$true,Position=0,HelpMessage="Von welchem User sollen Berechtigungen kopiert werden?")] | |
[String] | |
$fromUser, | |
[parameter(Mandatory=$true,Position=1,HelpMessage="Welcher User erhaelt die neuen Gruppen?")] | |
[String] | |
$toUser | |
) | |
$antwort = read-host "Sind Sie sicher? $fromUser --> $toUser (ja/nein)?" | |
if ($antwort -eq "ja") { | |
$UserGroups = Get-ADUser –Identity $fromUser -Properties memberOf | Select-Object -ExpandProperty memberOf | |
# check if Groups are Found | |
$UserGroups | % { | |
# Add User to each Group | |
Add-ADGroupMember -Identity "$($_)" -Members $toUser -ErrorAction SilentlyContinue | |
} | |
} | |
else { | |
write-host "Abbruch: Es wurden keine Gruppen kopiert!" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment