I do want to add that we spent an extra 20 minutes troubleshooting because we kept receiving access denied errors. It turns out that when he created the group he added his account (not domain admin) in the managed by field. Running the script under my DA account kept giving me those permission errors. The script only worked after removing his account from the managed by field. I was bit blindsided by that but overall a good learning experience. Anyways below is the script I used.
$sourceGroup = "SourceGroup Name"
$targetGroup = "TargetGroup Name"
Get-ADGroupMember -Identity $sourceGroup | foreach {$._SamAccountName} { $varName = $_.SamAccountName ; Add-ADGroupMember -Identity $targetGroup -Members $varName }
I'm thinking about developing this script so that it can ask for feedback instead of editing the script directly. It would make it friendly to anybody who isn't used to scripting. Stay tuned!
No comments:
Post a Comment