我想从Power Shell脚本为多个服务器启用IIS 8应用程序池中的自动启动和启动模式属性。我创建了一个适用于单个服务器的脚本。见下文:-
Import-Module WebAdministration
cd IIS:/AppPools
$ApplicationPools = dir
foreach ($item in $ApplicationPools)
{
$ApplicationPoolName = $item.Name
$pool = Get-Item $ApplicationPoolName
$pool.autoStart = 'false'
$pool.startmode = 'ondemand'
$pool | Set-Item
}
有人可以帮我编辑多个服务器吗?我所有的服务器都在域中。
请尝试以下:
$Servers = Get-Content C:\Users\Desktop\server.txt
$Servers | ForEach-Object {
Invoke-Command -ComputerName $_ -ScriptBlock {
Import-Module WebAdministration
cd IIS:/Sites
$Application = dir
foreach ($item in $Application)
{
$ApplicationName = $item.Name
$Website = Get-Item $ApplicationName
$Website.serverAutoStart = 'true'
$Website | Set-Item
}
cd IIS:/AppPools
$ApplicationPools = dir
foreach ($item in $ApplicationPools)
{
$ApplicationPoolName = $item.Name
$AppPool = Get-Item $ApplicationPoolName
$AppPool.autoStart = 'true'
$AppPool.startmode = 'alwaysrunning'
$AppPool | Set-Item
}
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句