我无法设置Exchange会话的超时值:
$testSessionOption = New-PSSessionOption -OperationTimeout 180000 -OpenTimeout 180000 -CancelTimeout 60000 -IdleTimeoutMs 240000
$UserCredential = Get-Credential
$tempSession = New-PSSession -SessionOption $testSessionOption -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $UserCredential -Authentication Basic -AllowRedirection
while ($true) {
Start-Sleep 300 # every five minutes
Write-Host 'STATE:' $tempSession.state
Write-Host 'AVAILIBILITY:' $tempSession.Availability
}
当我运行这段代码时,它只在运行四个小时后才断开连接。 我只想让代码在大约五分钟后断开连接... 而且,如果您运行它大约十分钟,您将永远看不到它断开连接!
我需要帮助使此脚本正常运行! 谢谢!