Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sam-Martin/cc796a4f6653c8ec5239 to your computer and use it in GitHub Desktop.
Save Sam-Martin/cc796a4f6653c8ec5239 to your computer and use it in GitHub Desktop.
Create standard user and enable PS Remoting in AWS UserData
<powershell>
Enable-PSRemoting -force
Set-Item WSMan:\localhost\MaxTimeoutms 1800000
Set-Item WSMan:\localhost\Service\AllowRemoteAccess $true
Set-Item WSMan:\localhost\Service\Auth\Basic $true
Set-item WSMan:\localhost\Service\AllowUnencrypted $true
$computername = $env:computername # place computername here for remote access
$username = 'AdminAccount1'
$password = 'topSecret@99'
$desc = 'Automatically created local admin account'
$computer = [ADSI]"WinNT://$computername,computer"
$user = $computer.Create("user", $username)
$user.SetPassword($password)
$user.Setinfo()
$user.description = $desc
$user.setinfo()
$user.UserFlags = 65536
$user.SetInfo()
$group = [ADSI]("WinNT://$computername/administrators,group")
$group.add("WinNT://$username,user")
</powershell>
@Sam-Martin
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment