Skip to content

Instantly share code, notes, and snippets.

@pcgeek86
Created January 8, 2015 19:33
Show Gist options
  • Save pcgeek86/9df3866406c66006f17e to your computer and use it in GitHub Desktop.
Save pcgeek86/9df3866406c66006f17e to your computer and use it in GitHub Desktop.
A helper function to connect to Microsoft Azure virtual machines using PowerShell Remoting. Visit http://trevorsullivan.net.
function Enter-AzurePSSession {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string] $ServiceName,
[Parameter(Mandatory = $true)]
[string] $VMName
)
$SessionOption = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck;
$WinRMUri = Get-AzureWinRMUri -ServiceName $ServiceName -Name $VMName;
$VMCredential = Get-Credential;
Enter-PSSession -ConnectionUri $WinRMUri -SessionOption $SessionOption -Credential $VMCredential;
}
Enter-AzurePSSession pcgeek101101 trevor03;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment