You can use timeouts to protect the local computer and the remote computer from excessive resource use, both accidental and malicious. When timeouts are set on both the local and remote computer, Windows PowerShell uses the shortest timeout settings. The following timeouts are available in the basic configuration.

When a timeout value does not permit a operation to complete, Windows PowerShell terminates the operation and generates an error. For example, Windows PowerShell generates the following error when the processing of a command exceeds the operation timeout that is set in the session.

  Copy Code
ERROR: The WS-Management service cannot complete the operation within the time specified in OperationTimeout.

To change a timeout value

  • To resolve the error, change the command to complete within the timeout interval or determine the source of the timeout limit and increase the timeout interval to allow the command to complete.

    For example, the following commands increase the OperationTimeout value. The first command uses the New-PSSessionOption cmdlet to create a session option object with an OperationTimeout value of 4 minutes (in MS). The second command uses the session option object to create a remote session with the extended OperationTimeout value.

      Copy Code
    C:\PS> $pso = new-pssessionoption -operationtimeout 240000
    C:\PS> new-pssession -computername Server01 -sessionOption $pso

    The following command sets the value of the $PSSessionOption preference variable to the session option with the four-minute OperationTimeout value. Thereafter, all PSSessions that you create during the current session have the extended operation timeout.

      Copy Code
    C:\PS> $PSSessionOption = new-pssessionoption -operationtimeout 240000

    To use the new session option in all PSSessions that you create on the computer, add the $PSSessionOption preference variable to your Windows PowerShell profile. For more information about Windows PowerShell profiles, see about_Profiles.

See Also