小编Sam*_*ain的帖子

通过power-shell检查AppPool状态并在远程机器上启动

要求是一一提取服务器名称,查看AppPool状态,如果发现停止,则让它运行。下面的代码没有帮助。

$ErrorActionPreference = "Continue"
$status = gc -path "D:\Servers\server.txt"|ForEach-Object (invoke-command -ComputerName $_ -ScriptBlock {Import-Module Webadministration Get-WebAppPoolState -name (gc "D:\AppPool.txt")})

if ($status.value -eq "Started") 
{
    Write-Host ("ApppPool already running")
}
else 
{
    Invoke-Command -ScriptBlock {Start-WebAppPool}
    Write-host ("AppPool has started successfully") 
}
Run Code Online (Sandbox Code Playgroud)

powershell powershell-4.0

2
推荐指数
1
解决办法
7635
查看次数

标签 统计

powershell ×1

powershell-4.0 ×1