Powershell – Add user to local administrators group

Add domain user/group

To see current server name:


To connect to current server Adminstrators group, type:

$srvgroup = [ADSI]("WinNT://"+$env:COMPUTERNAME+"/administrators, group")

To check server group connected you can query for is name:


To add an Active Directory user or group (example AD name is MYAD), type:


To check if new users or group were added correctly you can query group members:

$srvgroup.Invoke("Members") | foreach {$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)}


In Depth

Tested With
PowerShell 4.0

Categories: Powershell | Leave a comment

Post navigation

Leave a Reply

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

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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

Blog at WordPress.com.

%d bloggers like this: