简体   繁体   English

Azure PowerShell列表端点

[英]Azure PowerShell List Endpoints

We have an Azure account with a lot of VMs. 我们有一个包含大量VM的Azure帐户。 I need a script that can list all powered on machines that has endpoints - and list the endpoints + ACL. 我需要一个脚本,该脚本可以列出具有终结点的所有已打开电源的计算机-并列出终结点+ ACL。

We're trying to track down servers with open SSH endpoints without having to do it manually. 我们正在尝试追踪具有开放SSH端点的服务器,而无需手动进行。 The script that I tried to work didn't work. 我尝试使用的脚本无效。

Get-AzureVM | Get-AzureVM | where {$_.Status -ne "ReadyRole"} | 其中{$ _。Status -ne“ ReadyRole”} | Get-AzureEndpoint | Get-AzureEndpoint | select LocalPort, Port, Protocol, Vip, Acl, VirtualIPName 选择LocalPort,端口,协议,Vip,Acl,VirtualIPName

Thank you! 谢谢!

you need to step through each VM's endpoint: 您需要逐步了解每个VM的端点:

$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)"
      }
   }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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