Hi, everyone,
I created a script to copy AD permissions from one user to another or existing user.
For some reason the script didn’t work well I inserted the variable of the user name from which I want to copy but it can’t find me.
It is important to note that in AD I have USERS, a sub-OU of users like OU of Public, Private
# import the Active Directory module in order to be able to use get-ADuser and Add-AdGroupMembe cmdlet
import-Module ActiveDirectory
# enter login name of the first user
$copy = Read-host "Enter username to copy from: "
# enter login name of the second user
$paste = Read-host "Enter username to copy to: "
# copy-paste process. Get-ADuser membership | then selecting membership | and add it to the second user
get-ADuser -identity $copy -properties memberof | select-object memberof -expandproperty memberof | Add-AdGroupMember -Members $paste
This is an error message I receive:
Add-AdGroupMember : Insufficient access rights to perform the operation
At line:11 char:101
+ ... memberof -expandproperty memberof | Add-AdGroupMember -Members $paste
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (CN=CPT Helsinki...ba,DC=gov,DC=il:ADGroup) [Add-ADGroupMember], ADException
+ FullyQualifiedErrorId : ActiveDirectoryServer:8344,Microsoft.ActiveDirectory.Management.Commands.AddADGroupMember