Skip to content

Instantly share code, notes, and snippets.

View pkirch's full-sized avatar

Peter Kirchner pkirch

View GitHub Profile
@pkirch
pkirch / Upload-VHD.ps1
Last active August 29, 2015 14:06
Upload a VHD to Azure Storage Blob via PowerShell.
# Get administration certificate.
# Get-AzurePublishSettingsFile
# Import-AzurePublishSettingsFile -PublishSettingsFile "C:\Users\pkirch\Downloads\Azure MSDN - pkirchner-9-11-2014-credentials.publishsettings"
# Settings
$SubscriptionName = "Azure MSDN - pkirchner"
$StorageAccountName = "pkmsft"
$Container = "vhds"
$LocalVhd = "C:\Users\pkirch\fixedvhd20mb.vhd"
@pkirch
pkirch / Get-RelatedCommand.ps1
Created November 21, 2014 12:41
Get all related commands for a certain service.
# Sample by Peter Kirchner (peter.kirchner@microsoft.com)
PS C:\Users\pkirch> Get-Command -Module Azure -Noun AzureService
<# Output
CommandType Name ModuleName
----------- ---- ----------
Cmdlet Get-AzureService Azure
Cmdlet New-AzureService Azure
@pkirch
pkirch / Get-SubscriptionEndpoints1.ps1
Last active August 29, 2015 14:12
Get all endpoints in an Azure Subscription - first simple approach.
Get-AzureVM | Get-AzureEndpoint
<# Output
LBSetName :
LocalPort : 5986
Name : PowerShell
Port : 5986
Protocol : tcp
Vip : 104.40.188.19
@pkirch
pkirch / Get-SubscriptionEndpoints2.ps1
Created January 2, 2015 15:20
Get all endpoints in an Azure Subscription - second approach with formatted output.
Get-AzureVM | Get-AzureEndpoint | Select-Object -Property Vip, Name, Port, LocalPort | Format-Table -AutoSize
<# Output
Vip Name Port LocalPort
--- ---- ---- ---------
104.40.188.19 PowerShell 5986 5986
104.40.188.19 Remote Desktop 56595 3389
191.233.81.126 PowerShell 5986 5986
191.233.81.126 Remote Desktop 61942 3389
@pkirch
pkirch / Get-SubscriptionEndpoints3.ps1
Created January 2, 2015 15:23
Get all endpoints in an Azure Subscription - third approach with formatted output and related cloud service and VM name.
# Get all Azure VMs in the current subscription.
Get-AzureVM | ForEach-Object {
# Save the current VM for use in the nested ForEach.
$vm = $_
# Get all endpoints of the current VM.
$endpoints = Get-AzureEndpoint -VM $vm
# Iterate all endpoints of the current VM.
$output = $endpoints | ForEach-Object {
# Create our own set of properties we want for output.
$hashtable = @{ServiceName=$vm.ServiceName; InstanceName=$vm.InstanceName; DNSName=$vm.DNSName; Protocol=$_.Name; Vip=$_.Vip; ExternalPort=$_.Port; InternalPort=$_.LocalPort}
@pkirch
pkirch / Get-LabelCommands.ps1
Created January 7, 2015 20:40
This sample lists all Azure cmdlets which support the parameter Label.
Get-Command -Module Azure | Where-Object {$_.Parameters.Keys -contains "Label"}
<# Output
CommandType Name ModuleName
----------- ---- ----------
Cmdlet Add-AzureDisk Azure
Cmdlet Add-AzureVMImage Azure
Cmdlet New-AzureAffinityGroup Azure
Cmdlet New-AzureDeployment Azure
@pkirch
pkirch / Get-DescriptionCommands.ps1
Created January 7, 2015 20:42
This sample lists all Azure cmdlets which support the parameter Description.
Get-Command -Module Azure | Where-Object {$_.Parameters.Keys -contains "Description"}
<# Output
CommandType Name ModuleName
----------- ---- ----------
Cmdlet Add-AzureVMImage Azure
Cmdlet New-AzureAffinityGroup Azure
Cmdlet New-AzureAutomationRunbook Azure
Cmdlet New-AzureAutomationSchedule Azure
@pkirch
pkirch / LabelDescription.ps1
Created January 7, 2015 20:45
This sample sets and gets the label and description for a cloud service.
Set-AzureService -ServiceName leasetest2 -Description "This cloud service contains all frontend VMs, which are grouped into two availabilty groups." -Label "Frontend West EU"
<# Output
OperationDescription OperationId OperationStatus
-------------------- ----------- ---------------
Set-AzureService 54a6c394-f6d5-5d14-9496-ddaa1ad9076c Succeeded
#>
@pkirch
pkirch / MVA01-AzureVM.ps1
Last active August 29, 2015 14:13
This sample creates a new cloud service, storage account and VM.
# Sample by Peter Kirchner (peter.kirchner@microsoft.com)
# Settings
$subscriptionName = "MSFT MVA Live" # Get-AzureSubscription
$location = "West Europe" # Get-AzureLocation
$serviceName = "pktestservice"
$storageAccountName = "pkteststorage"
$storageContainerName = "vhds"
$adminUsername = "adm_test"
$adminPassword = "Azureisttoll!"
@pkirch
pkirch / MVA02-Endpoints.ps1
Last active August 29, 2015 14:13
This sample shows three ways to get the endpoints in an Azure subscription.
# sample 1
Get-AzureVM | Get-AzureEndpoint
# sample 2
Get-AzureVM | Get-AzureEndpoint | Select-Object -Property Vip, Name, Port, LocalPort | Format-Table -AutoSize
# sample 3
Get-AzureVM | ForEach-Object {
# Save the current VM for use in the nested ForEach.
$vm = $_