Skip to content

Instantly share code, notes, and snippets.

@LawrenceHwang
Created March 20, 2017 01:19
Show Gist options
  • Save LawrenceHwang/043c6e3a7d0c5208f77021ab09832033 to your computer and use it in GitHub Desktop.
Save LawrenceHwang/043c6e3a7d0c5208f77021ab09832033 to your computer and use it in GitHub Desktop.
$instances = Get-ec2instance -Filter @(@{name = 'platform'; value = 'windows'})
foreach ($i in $instances){
$prop = @{
Name = $i.Name
password = Get-EC2PasswordData -InstanceId $i.InstanceId -PemFile "C:\path\to\private\keys\$($i.KeyName).pem"
InstanceId = $i.instances.InstanceId
}
$obj = New-Object -TypeName psobject -Property $prop
$obj
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment