Skip to content

Instantly share code, notes, and snippets.

@SevenLayerJedi
Created January 3, 2019 17:39
Show Gist options
  • Save SevenLayerJedi/d89b9815059bc8af4bbb8351c5ed8cf3 to your computer and use it in GitHub Desktop.
Save SevenLayerJedi/d89b9815059bc8af4bbb8351c5ed8cf3 to your computer and use it in GitHub Desktop.
# Get List of Users
net user
# Get List of Local Groups
net localgroup
# Create user "bmarley"
net user /add bmarley S3cretP@ssword /add
# Add BMARLEY to local administrators group
NET LOCALGROUP "administrators" "bmarley" /add
# Create a user account with no password
New-LocalUser -Name "bmarley" -Description "Bob Marley's Account" -NoPassword
# Create a user account that has a password
$Password = Read-Host -AsSecureString
New-LocalUser "bmarley" -Password $Password -FullName "Bob Marley" -Description "Bob Marley's account"
# Create a user account that is connected to a Microsoft account
New-LocalUser -Name "MicrosoftAccount\usr bmarley@Outlook.com" -Description "Bob Marley's account"
# Use PSEXEC to add
psexec \\RemoteComputerName net localgroup administrators "bmarley" /add
# Powershell add local user to local admin group
$ComputerName = "RemoteComputerName"
$UserName = "bmarley"
$AdminGroup = [ADSI]"WinNT://$ComputerName/Administrators,group"
$User = [ADSI]"WinNT://$UserName,user"
$AdminGroup.Add($User.Path)
# Powershell remotely remove local user from local admin group
psexec \\RemoteComputerName net localgroup administrators "bmarley" /delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment