Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Set primary group in AD using PowerShell

$
0
0

Dear All!

I need a hint :)

 

I am creating a script that creates AD Users, creates HomeFolders with special security settings, sets their groups and creates an Mailbox (Exchange).

For users from different countries I need to use different Domain Controllers. This works, except of setting the primary group.

If I create the user on the logonserver of the server from which the script is executed it works, but not on others.

The part of the script I use for setting the primary group is:

"

$userP = Get-QADuser $login
$groupP = Get-QADGroup $mainGroupSec
$groupP | Add-QADGroupMember -Member $login
$userP | Set-QADUser -ObjectAttributes @{PrimaryGroupID=$groupP.PrimaryGroupToken} | Remove-QADGroupMember

"

Is there any way to set the server where to do this? Like f.e. Set-ADuser -server $DCServer?

Or is there a way to do this without using the Quest.ActiveRoles.ADManagementsnapin?

Thanks for any suggestion.

Best Regards,

Daniel

 

 

 

 

 

 

 

 


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>