我想在IIS 8应用程序池中为power shell脚本中的多个服务器启用自动启动和启动模式属性.我创建了一个适用于单个服务器的脚本.见下文:-
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
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮助我编辑多个服务器.我所有的服务器都在域中.
有人可以帮助我从power shell创建网站.我在下面写的脚本不起作用.
Import-Module WebAdministration
#navigate to the app pools root
cd IIS:\AppPools\
#check if the app pool exists
if (!(Test-Path $iisAppPoolName -pathType container))
{
#create the app pool
$appPool = New-Item $iisAppPoolName
$appPool | Set-ItemProperty -Name "managedRuntimeVersion" -Value $iisAppPoolDotNetVersion
}
#navigate to the sites root
cd IIS:\Sites\
#check if the site exists
if (Test-Path $iisAppName -pathType container)
{
return
}
#create the site
$iisApp = New-Item $iisAppName -bindings @{protocol="http";bindingInformation=":80:" + $iisAppName} -physicalPath $directoryPath
$iisApp | Set-ItemProperty -Name "applicationPool" -Value $iisAppPoolName
Run Code Online (Sandbox Code Playgroud) powershell ×2