-
-
Save ciphertxt/a9f7669f50d82c6e4b49 to your computer and use it in GitHub Desktop.
This file contains 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
function azrdp { | |
<# | |
.Author | |
Trevor Sullivan <[email protected]> | |
.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