Categories

Archives

Adding Computers to AD Group with Powershell

Adding computers from a text file like:

pc1
pc2
pc3
pc4
...

using powershell could look like that:

1
2
Get-Content "C:\file.txt" | ForEach-Object {Get-QADComputer $_ |`
 Add-QADGroupMember -Credential $usercredential -Identity "our_ad_group" }

Everything should be pretty clear, in the variable $usercredential are credentials for the user which has rights to modify AD group membership.
You can set it at any time with

1
$UserCredential = Get-Credential

I am personally setting it in the powershell profile so it’s always available after starting powershell window.

This post is also available in: German, Polish

Comments are closed.