问题
I am using the PST Capture Console from Microsoft to import PSTs into Office 365. I use the following to open a session to Office 365.
$UserCredential = Get-Credential
$Session = -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
This will connect and allow me to start an import and I am able to do small PSTS; however when I try to import large PST files the session times out after 3 hours.
I tried using the -IdleTimeout cmdlet but it is not recongized. More research shows that you need to use the -PSSessionOption to be able to set the timeout to never expire (as I want it to only expire when I force remove it). I cannot figure out how to reconfigure my script to work with the -PSSessionOption.
回答1:
from the doc
The session uses the idle timeout that is set in the session options, if any. If none is set (-1), the session uses the value of the IdleTimeoutMs property of the session configuration or the WSMan shell timeout value (WSMan:\\Shell\IdleTimeout), whichever is shortest. If the idle timeout set in the session options exceeds the value of the MaxIdleTimeoutMs property of the session configuration, the command to create a session fails. The IdleTimeoutMs value of the default Microsoft.PowerShell session configuration is 7200000 milliseconds (2 hours). Its MaxIdleTimeoutMs value is 2147483647 milliseconds (>24 days). The default value of the WSMan shell idle timeout (WSMan:\\Shell\IdleTimeout) is 7200000 milliseconds (2 hours).
so you could try to globaly modify timeout for all sessions like that :
Set-Item -path WSMan:\localhost\Shell\IdleTimeout -Value ''
来源:https://stackoverflow.com/questions/28116985/powershell-idle-timeout