Created
March 8, 2016 14:21
-
-
Save Sam-Martin/cc796a4f6653c8ec5239 to your computer and use it in GitHub Desktop.
Create standard user and enable PS Remoting in AWS UserData
This file contains hidden or 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
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Stolen carte-blanche from http://powershell.com/cs/blogs/tips/archive/2011/09/12/creating-local-admins.aspx