Udostępnij za pośrednictwem


Document everything you want to know about your Azure IaaS VMs in one line of PowerShell

Mark Renoden, one of my colleagues from Microsoft Australia/New Zealand has come up with this great single line of powershell that spits out everything you want to know about your VMs

Get-AzureVM | ForEach-Object { $vm = $_.name ; Write-Output "$vm VM Properties" ; Write-Output "---------------" ; Format-List -InputObject $_ -Property * ; Write-Output "$vm VM Endpoints" ; Write-Output "---------------" ; Get-AzureEndpoint -VM $_ ; Write-Output "$vm Virtual Disks" ; Write-Output "---------------" ; Get-AzureDisk | where {$_.AttachedTo.RoleName -eq $vm} ; Write-Output "==================================`n" } | Out-File -FilePath ".\myVMs.txt”

Here’s an example output:::

DeploymentName              : planky1
Name                        : planky1
Label                       :
VM                          : Microsoft.WindowsAzure.Commands.ServiceManagement.Model.PersistentVM
InstanceStatus              : ReadyRole
IpAddress                   : 100.74.110.11
InstanceStateDetails        :
PowerState                  : Started
InstanceErrorCode           :
InstanceFaultDomain         : 0
InstanceName                : planky1
InstanceUpgradeDomain       : 0
InstanceSize                : Small
AvailabilitySetName         :
DNSName                     : https://planky.cloudapp.net/
Status                      : ReadyRole
GuestAgentStatus            : Microsoft.WindowsAzure.Commands.ServiceManagement.Model.PersistentVMModel.Guest
                              AgentStatus
ResourceExtensionStatusList : {Microsoft.Compute.BGInfo}
PublicIPAddress             :
PublicIPName                :
ServiceName                 : planky
OperationDescription        : Get-AzureVM
OperationId                 : 26f35d0c908f2ad8961a2516f4b8c8a1
OperationStatus             : OK

planky1 VM Endpoints
---------------

LBSetName                :
LocalPort                : 5986
Name                     : PowerShell
Port                     : 5986
Protocol                 : tcp
Vip                      : 191.239.212.49
ProbePath                :
ProbePort                : 0
ProbeProtocol            :
ProbeIntervalInSeconds   :
ProbeTimeoutInSeconds    :
EnableDirectServerReturn : False
Acl                      : {}
InternalLoadBalancerName :

LBSetName                :
LocalPort                : 3389
Name                     : Remote Desktop
Port                     : 58168
Protocol                 : tcp
Vip                      : 191.239.212.49
ProbePath                :
ProbePort                : 0
ProbeProtocol            :
ProbeIntervalInSeconds   :
ProbeTimeoutInSeconds    :
EnableDirectServerReturn : False
Acl                      : {}
InternalLoadBalancerName :

planky1 Virtual Disks
---------------
AffinityGroup        :
AttachedTo           : RoleName: planky1
                       DeploymentName: planky1
                        HostedServiceName: planky
IsCorrupted          : False
Label                :
Location             : North Europe
DiskSizeInGB         : 128
MediaLink            : https://plankydevcamp.blob.core.windows.net/vhds/planky-planky1-2014-09-25.vhd
DiskName             : planky1-planky1-0-201409250848400102
SourceImageName      : a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201409.01-en.us-127GB.vhd
OS                   : Windows
OperationDescription : Get-AzureDisk
OperationId          : 0f3e0975-06d0-2059-856c-3c6f6d9d1953
OperationStatus      : Succeeded

==================================

 

Isn’t that just soooo cool. Thanks Mark!

 

Yours etc,

 

Planky