Powershell: Add User to a lot of Groups

image 

Update: Dimitry Sotnikov has posted a great article about the new cmdlets. You can read his post here.  After reading Dimitry’s post, I created a new script.

For some test purposes I created a new test user. This test user has to be a member off al my application groups in Active Directory. This job can easily  be done with Powershell and the Quest AD cmdlets.

 
$User = Read-Host ("Username")
Get-QADGroup -Name 'GG_APL_*' -NotContainsIndirectMember $User `
    | Add-QADGroupMember -Member $User

 

To verify the changes, you can run the following script:

$User = Read-Host ("Username")
Get-QADGroup $User | Select Name 
Advertisement

One Response to Powershell: Add User to a lot of Groups

  1. In PowerShell is het mogelijk om arrays te gebruiken zonder er een ForEach loopje omheen te schrijven. Of dat in dit specifieke geval te gebruiken is, zul je even moeten testen. De beschrijving van dit principe vind je terug op het volgende URL: http://www.microsoft.com/technet/scriptcenter/resources/pstips/jun07/pstip0622.mspx

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 902 other followers