【发布时间】:2018-08-08 17:54:10
【问题描述】:
我随机得到以下错误
WS-Management 服务 无法处理请求。此用户最多允许 5 个并发 shell,已超过该数量。关闭现有 壳或提高此用户的配额。有关详细信息,请参阅 about_Remote_Troubleshooting 帮助主题。
我的示例代码如下所示
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。
如果我做得对,请有人告诉我
【问题讨论】:
标签: powershell