停止Get-WmiObject命令

我正在运行一个脚本来耗尽服务器,因此每当服务器关闭时,该脚本将花费很长时间才能完成,是否可以使此命令超时?

我试图在开始工作中使用它,但没有成功。

$RDSH = Get-Wmiobject -Class "Win32_TerminalServiceSetting" -Namespace "root\CIMV2\terminalservices" -ComputerName "RDServer" -Authentication PacketPrivacy -Impersonation Impersonate
$RDSH.SessionBrokerDrainmode = Read-Host -Prompt '0 to open 1 to close:'
If($RDSH.SessionBrokerDrainmode -eq 0 -or $RDSH.SessionBrokerDrainmode -eq 1){
$RDSH.put() > $null
Write-Host "$RDServer is set to:"
switch ($RDSH.SessionBrokerDrainmode)
{
0 {"Allow all connections."}
1 {"Allow incoming reconnections but until reboot prohibit new connections."}
2 {"Allow incoming reconnections but prohibit new connections."}
default {"The user logon state cannot be determined."}
}}
cimsimon 回答:停止Get-WmiObject命令

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3143003.html

大家都在问