How to add a user to the administrators group using PowerShell

Home > Search > How-to

This command can be used to add a local user account to a group (such as administrators) using PowerShell.

  • Replace ComputerName with the hostname of the computer
  • Replace username with the username of the account to add to the group


If on a domain, use the DomainName instead of the ComputerName.



This command can be used to view the members of the group.

gwmi -query "select PartComponent, __Server from Win32_GroupUser where GroupComponent=`"Win32_Group.Domain='$env:Computername',Name='$localgroup'`"" |
  % { [WMI] $_.PartComponent } |
  ft -a Domain, Name, FullName, Description


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter in the box below so that we can be sure you are a human.