获取所有服务器

$virtds = "ECP,OWA,OAB,WebServices,Activesync"  
 $array = $virtds.split(",")  
 foreach ($i in $array) {  
 $j = "Get-"+$i+"VirtualDirectory"+" | fl name,server,internalurl,externalurl"  
 invoke-expression $j   
 } 

获取单个服务器

 $virtds = "ECP,OWA,OAB,WebServices,Activesync"  
 $array = $virtds.split(",")  
 foreach ($i in $array) {  
 $j = "Get-"+$i+"VirtualDirectory"+" -Server ex1601| fl name,server,internalurl,externalurl"  
 invoke-expression $j   
 } 

您也可以关注下方微信公众号获取更多内容