Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 无法通过Powershell停止IIIS WAS进程_Windows_Powershell_Iis 7.5_Powershell 2.0_Was - Fatal编程技术网

Windows 无法通过Powershell停止IIIS WAS进程

Windows 无法通过Powershell停止IIIS WAS进程,windows,powershell,iis-7.5,powershell-2.0,was,Windows,Powershell,Iis 7.5,Powershell 2.0,Was,在Windows Server 2008 R2 64位计算机上,我正在运行以下代码: $global:arrServer=@(“ph1”、“ph2”、“ph3”) $global:arrDienste=@(“W3SVC”、“WAS”、“IISADMIN”) $global:strPfad=“D:\WASLogs\” $global:strLogTime=获取日期-格式为“yyyy-MM-dd--hh-MM-ss” $global:strLogDatei=$global:strPfad+“WART

在Windows Server 2008 R2 64位计算机上,我正在运行以下代码:

$global:arrServer=@(“ph1”、“ph2”、“ph3”)
$global:arrDienste=@(“W3SVC”、“WAS”、“IISADMIN”)
$global:strPfad=“D:\WASLogs\”
$global:strLogTime=获取日期-格式为“yyyy-MM-dd--hh-MM-ss”
$global:strLogDatei=$global:strPfad+“WARTUNG--”+$global:strLogTime+“.log”
日志和日志
迪恩斯特站
函数Dienste_Stop
{
echo“服务停止成功?”|输出文件$global:strLogDatei-Append-Force
foreach($global:arrServer中的strServer)
{
$strInterim2=$strServer+“(+$global:appServerNamen+”)
echo“$strInterim2”输出文件$global:strLogDatei-Append-Force
foreach($global:arrdienst中的strdinst)
{
$objWmiService=Get Wmiobject-Class“win32_服务”-计算机$strServer-filter“name=”$strienst“
if($objWmiService.State)
{
$rtnWert=$objWmiService.stopService()
开关($rtnWert.returnvalue)
{
0{echo“$strdinst stopped!”|输出文件$global:strLogDatei-Append-Force}
2{echo“$strdinst抛出:'拒绝访问!'”|输出文件$global:strLogDatei-Append-Force}
3{echo“服务$strienst在$strServer上不存在!”|输出文件$global:strLogDatei-Append-Force}
5{echo“$strdinst已停止!”|输出文件$global:strLogDatei-Append-Force}
默认值{echo“$strdinst服务报告错误$($rtnWert.returnValue)”|输出文件$global:strLogDatei-Append-Force}
}
}
其他的
{
echo“服务$strienst在$strServer上不存在!”|输出文件$global:strLogDatei-Append-Force
}
}
}
}
函数日志
{
如果([IO.Directory]::存在($global:strPfad))
{
echo“这里什么也没发生。”
}
其他的
{
新项目-项目类型目录-路径$global:strPfad
}
}
这可以在所有ph1、ph2和ph3计算机上复制。但是用一些其他的代码,可以分别启动,状态可以看到

还应注意:

  • 是否可以停止所有其他服务?这是否与WAS的路径是这样的事实有关?C:\Windows\system32\svchost.exe-k iissvcs
  • 我故意使用WMI
  • 这是怎么回事


    Tia

    问题可能是依赖WAS的多个服务需要首先停止。该方法没有用于停止依赖服务的重载。如果这不能解决问题,请检查StopService的响应代码,以确定上面链接中的问题

    看起来您正在处理代码3,因为“服务不存在”。文档显示此代码实际上意味着“该服务无法停止,因为正在运行的其他服务依赖于它。”

    不确定在powershell中完全使用此功能时为何决定使用WMI

    Stop-Service WAS -Force
    

    问题可能是有多个依赖WAS的服务需要首先停止。该方法没有用于停止依赖服务的重载。如果这不能解决问题,请检查StopService的响应代码,以确定上面链接中的问题

    看起来您正在处理代码3,因为“服务不存在”。文档显示此代码实际上意味着“该服务无法停止,因为正在运行的其他服务依赖于它。”

    不确定在powershell中完全使用此功能时为何决定使用WMI

    Stop-Service WAS -Force