获取所有服务器 ``` $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 } ``` 您也可以关注下方微信公众号获取更多内容 ![](https://s1.51cto.com/images/blog/201903/24/6d0895bb514502fdda21699de558153d.jpg?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)