Add User To local Group On Multiple Computer Using PowerShell

In this blog post, I will show you how to add a domain user to a local group on multiple servers using PowerShell.

Local Groups

In my scenario, I have multiple servers that I need to give a specific user remote access to.

In order to do that, I need to add the user to the Remote Desktop Users Group, which is a built-in group in Windows Server.


Below is the code, and if you look closely you will see the servers that I will add him to and the name of the group.

Invoke-Command -ComputerName WINSERVER01, WINSERVER02 -ScriptBlock {add-LocalGroupMember -Group "Remote Desktop Users" -Member username }

The code can be run from any domain-joined machine as long as the user that runs it is a domain admin or he is a member of the local administrators’ group on each machine.

Success! You're on the list.