Last active
March 1, 2018 08:58
-
-
Save Oceanswave/876fab9bf87de09b1b9c to your computer and use it in GitHub Desktop.
Powershell function to add a user to a local group
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Add-LocalUser{ | |
Param( | |
$computer=$env:computername, | |
$group='Guests', | |
$userdomain=$env:userdomain, | |
$username=$env:username | |
) | |
([ADSI]"WinNT://$computer/$Group,group").psbase.Invoke("Add",([ADSI]"WinNT://$domain/$user").path) | |
} | |
#Non-powershell equiv: | |
#net localgroup administrators mydomain.local\user1 /add |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment