This command can be used to add a local user account to a group (such as administrators) using PowerShell.
([adsi]"WinNT://ComputerName/administrators,group").Add("WinNT://ComputerName/username,user")
If on a domain, use the DomainName instead of the ComputerName.
([adsi]"WinNT://ComputerName/administrators,group").Add("WinNT://DomainName/username,user")
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