Add User To The Local Administrators Group On Multiple Computers Using PowerShell

In this blog post, I’ll show you how I add a Domain user to the Local Administrators group on multiple computers using a one-liner PowerShell code.

I have to say that while I was researching this task I came across many blogs and posts that showed how to do it but all method we too complicated and didn’t scale.

My one-liner of code can be scaled easily without any problem to 20 or 30 computers.


To achieve the objective I’m using the Invoke-Command PowerShell cmdlet which allows us to run PowerShell commands to local or remote computers.

In the example below, I’ll add my User David Azure (davidA) to the local Administrators group on two Server (win27, Win28)

Invoke-Command -ComputerName Server01, Server02 -ScriptBlock {add-LocalGroupMember -Group "Remote Desktop Users" -Member USER }

Learn More

To learn more about Invoke-Command run the line below In PowerShell

get-help Invoke-Command -Examples