Last active
August 29, 2015 14:13
-
-
Save pkirch/ab9c9ec3cd2314b47438 to your computer and use it in GitHub Desktop.
This sample shows three ways to get the endpoints in an Azure subscription.
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
# 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 = $_ | |
# 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} | |
# Create a new PowerShell object for output. | |
New-Object PSObject -Property $hashtable | |
} | |
$output | |
} | Format-Table -Property ServiceName, InstanceName, Vip, Protocol, ExternalPort, InternalPort, DNSName -AutoSize | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This sample script is used in the Microsoft Virtual Academy Course "PowerShell: Azure-Automatisierung für Einsteiger" at http://www.microsoftvirtualacademy.com/training-courses/powershell-azure-automatisierung-f-r-einsteiger-.