我正在运行一个脚本来耗尽服务器,因此每当服务器关闭时,该脚本将花费很长时间才能完成,是否可以使此命令超时?
我试图在开始工作中使用它,但没有成功。
$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."}
}}