Skip to content

Instantly share code, notes, and snippets.

@pcting
Created February 25, 2011 03:24
Show Gist options
  • Save pcting/843327 to your computer and use it in GitHub Desktop.
Save pcting/843327 to your computer and use it in GitHub Desktop.
set-admin-password.ps1, Powershell script to reset the admin password for Eucalyptus instances
param(
[int] $len = 6,
[string] $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"
)
$bytes = new-object "System.Byte[]" $len
$rnd = new-object System.Security.Cryptography.RNGCryptoServiceProvider
$rnd.GetBytes($bytes)
$result = ""
for( $i=0; $i -lt $len; $i++ )
{
$result += $chars[ $bytes[$i] % $chars.Length ]
}
Write-Host "Administrator password reset to $result"
net user administrator $result
$port= new-Object System.IO.Ports.SerialPort COM1
$port.open()
$port.write("** Access Credentials **`n`nUsername: administrator`nPassword: $result`n")
$port.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment