The following script allows you to specify a source user account and a destination user account to copy the group memberships from one to the other.
Syntax:
copyGroups.ps1 -sourceIdentity test.user1 -destinationIdentity test.user2
========================
copyGroups.ps1
========================
#Begin Script
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# copyGroups.ps1
#
# For the 'sourceIdentity' and 'destinationIdentity' parameters, provide the username of the user.
#
# Syntax:
# copyGroups.ps1 -sourceIdentity test.user1 -destinationIdentity test.user2
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Param([string]$sourceIdentity = "",[string]$destinationIdentity = "")
function checkParameters
{
if ($sourceIdentity -eq "")
{
throw "The source identity must be specified with the -sourceIdentity switch."
exit
}
if ($destinationIdentity -eq "")
{
throw "The destination identity must be specified with the -destinationIdentity switch."
exit
}
}
function copyGroups
{
get-qadmemberof -Identity $sourceIdentity | ForEach-Object {add-qadmemberof -identity $destinationIdentity -Group $_.Name}
}
checkParameters
copyGroups
#End Script