我想将 4 个 foreach 循环结果显示为:
Server
IIS Site:
App Pool:
Service:
代替:
Server
IIS Site:
Server
App Pool:
Server
Service:
代码:
foreach ($server in $servers)
{
foreach ($IISsite in $IISsites) { }
foreach ($appPool in $appPools) { }
foreach ($service in $services) { }
}
CheckSitesAppPoolsServices -servers "SERVER1" -IISsites ("Default Web Site")
CheckSitesAppPoolsServices -servers "SERVER1" -appPools ("DefaultAppPool")
CheckSitesAppPoolsServices -servers "SERVER1" -services ("User Profile Service", "App Readiness")
实际结果:
Review Sites, App Pools and Service on SERVER1
Default Web Site....................................... Started
Review Sites, App Pools and Service on SERVER1
DefaultAppPool......................................... Started
Review Sites, App Pools and Service on SERVER1
User Profile Service................................... Running
App Readiness.......................................... Stopped
我希望结果显示如下:
Review Sites, App Pools and Service on SERVER1
Site: Default Web Site....................................... Started
App Pool: DefaultAppPool......................................... Started
Service: User Profile Service................................... Running
Service: App Readiness.......................................... Stopped