Skip to content

Instantly share code, notes, and snippets.

@ciphertxt
Forked from pcgeek86/azrdp.ps1
Last active August 29, 2015 14:17
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 ciphertxt/a9f7669f50d82c6e4b49 to your computer and use it in GitHub Desktop.
Save ciphertxt/a9f7669f50d82c6e4b49 to your computer and use it in GitHub Desktop.
function azrdp {
<#
.Author
Trevor Sullivan <pcgeek86@gmail.com>
.Description
Invoke a RDP session to an Azure Virtual Machine, without having to type the
Cloud Service name or Virtual Machine name.
.Outputs
None
.Links
http://trevorsullivan.net
http://twitter.com/pcgeek86
#>
[CmdletBinding()]
param (
)
try {
$VM = Get-AzureVM -ErrorAction Stop | Out-GridView -PassThru;
if (!$VM) {
Write-Warning -Message 'No virtual machine was selected.';
return;
}
Get-AzureRemoteDesktopFile -ServiceName $VM.ServiceName -Name $VM.Name -Launch;
}
catch [System.ArgumentException] {
if ($PSItem.Exception.Message -match 'Add-AzureAccount') {
Add-AzureAccount;
& $PSCmdlet.MyInvocation.MyCommand.Name @PSBoundParameters;
}
}
}
azrdp;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment