WS-Management服务无法处理以下请求:Powershell
我随机得到下面的错误 WS-Management服务 无法处理该请求。此用户最多允许5个并发Shell,已超过此限制。封闭现有 取消或提高此用户的配额。有关更多信息,请参阅关于远程故障排除帮助主题 我的示例代码如下所示WS-Management服务无法处理以下请求:Powershell,powershell,Powershell,我随机得到下面的错误 WS-Management服务 无法处理该请求。此用户最多允许5个并发Shell,已超过此限制。封闭现有 取消或提高此用户的配额。有关更多信息,请参阅关于远程故障排除帮助主题 我的示例代码如下所示 try { $serverlist=server1...server100 foreach($computer in $computers) { Enter-PSSession -ComputerName $computer $Ostyp
try
{
$serverlist=server1...server100
foreach($computer in $computers)
{
Enter-PSSession -ComputerName $computer
$Ostype = (Get-WmiObject -Class Win32_OperatingSystem -ComputerName $computer -ErrorAction SilentlyContinue ).Caption
Exit-PSSession
}
}
Catch
{
[System.Windows.MessageBox]::Show($_.exception.message)
}
finally
{
Exit-pssession
}
在我执行脚本的过程中,有时会出现错误,因此上面的错误让我相信,我没有正确地关闭PSsession
有人能告诉我我做得是否正确吗试试下面的代码。它不使用交互式会话,而是使用Invoke命令cmdlet
try
{
$serverlist=server1...server100
foreach($computer in $computers)
{
$s = New-PSSession -ComputerName $computer
Invoke-Command -Session $s -ScriptBlock {$os = (Get-WmiObject -Class Win32_OperatingSystem -ComputerName $computer -ErrorAction SilentlyContinue ).Caption}
Remove-PSSession -Session $s
}
}
Catch
{
[System.Windows.MessageBox]::Show($_.exception.message)
}
请尝试以下代码。它不使用交互式会话,而是使用Invoke命令cmdlet
try
{
$serverlist=server1...server100
foreach($computer in $computers)
{
$s = New-PSSession -ComputerName $computer
Invoke-Command -Session $s -ScriptBlock {$os = (Get-WmiObject -Class Win32_OperatingSystem -ComputerName $computer -ErrorAction SilentlyContinue ).Caption}
Remove-PSSession -Session $s
}
}
Catch
{
[System.Windows.MessageBox]::Show($_.exception.message)
}
解决方案1:我们可以使用下面的命令删除现有的PS会话 获取PSSession |删除PSSession 解决方案2:重新启动IIS Exchange服务器 解决方案3:终止Comupter上的allwsmprovhost.exe进程 解决方案4:更新用户的限制策略,并将限制提高到更高的值,例如30,运行
设置ThrottlingPolicy Default*-PowerShellMaxConcurrency 30将其设置为解决方案1:我们可以使用下面的命令删除现有的PS会话 获取PSSession |删除PSSession 解决方案2:重新启动IIS Exchange服务器 解决方案3:终止Comupter上的allwsmprovhost.exe进程 解决方案4:更新用户的限制策略,并将限制提高到更高的值,例如30,运行
设置ThrottlingPolicy Default*-PowerShellMaxConcurrency 30将其设置为以澄清答案:Remove-PSSession应确实删除会话(其中Exit-PSSession将使其处于断开连接状态)。要澄清答案:Remove-PSSession应确实删除会话(其中Exit-PSSession将使其处于断开连接状态).#1是我需要的解决方案。但每次执行/迭代都会使重做过程更加接近会话。#1是我需要的解决方案。但重做过程将在每次执行/迭代时更加接近会话。