简体   繁体   中英

Azure PowerShell List Endpoints

We have an Azure account with a lot of VMs. I need a script that can list all powered on machines that has endpoints - and list the endpoints + ACL.

We're trying to track down servers with open SSH endpoints without having to do it manually. The script that I tried to work didn't work.

Get-AzureVM | where {$_.Status -ne "ReadyRole"} | Get-AzureEndpoint | select LocalPort, Port, Protocol, Vip, Acl, VirtualIPName

Thank you!

you need to step through each VM's endpoint:

$ReadyVMs = Get-AzureVM | ? Status -eq ReadyRole
ForEach ($VM in $ReadyVMs) {
   $EndPoint = $VM | Get-AzureEndpoint
   If ($EndPoint.LocalPort -eq 22) { #or whatever port you need
      If (($EndPoint.Acl).Count -gt 0) {
         $EndPoint.Acl
      }
      Else {
         Write-Host "No ACL found for $($EndPoint.Name) on $($VM.Name)"
      }
   }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM