- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use –Timeout parameter in Restart-Computer cmdlet in PowerShell?
As the name describes, with –Timeout parameter, you can restrict time for validations (PowerShell, WinRM, and WMI connectivity check after reboot) for –Wait and –For parameters and if the checks don’t complete during that time then it returns an error. This timeout value is in seconds. You can specify this parameter with either –Wait or –For parameter but with –For parameter you need to include –Wait parameter as well.
When -Timeout is specified with –Wait parameter, the overall checks (3 validations: PowerShell, WMI, and WINRM connectivity) then overall check time is restricted in seconds and when it is used with –For parameter then particular check time is considered.
In the below example, we are restarting Test1-Win2k12 remote server, and the timeout is 10 seconds. Server reboots and when the server comes up and if the checks don’t pass in 10 seconds then returns an error.
Restart-Computer Test1-Win2k12 -Wait -Timeout 10 -Force
Output (validation didn’t pass in 10 seconds) −
PS C:\Windows\system32> Restart-Computer Test1-Win2k12 -Wait -Timeout 10 Restart-Computer : Failed to restart the computer Test1- Win2k12 with the following error message: The computer did not finish restarting within the specified timeout period.. At line:1 char:1 + Restart-Computer Test1-Win2k12 -Wait -Timeout 10 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \+ CategoryInfo : OperationTimeout: (Test1- Win2k12:String) [Restart-Computer], RestartComputerTimeoutException + FullyQualifiedErrorId : RestartComputerTimeout,Microsoft.PowerShe ll.Commands.RestartComputerCommand
You can also specify the -Timeout parameter with –Wait and –For both.
Restart-Computer Test1-Win2k12 -Wait -For PowerShell -Timeout 10 -Force
- Related Articles
- How to use –Wait parameter in Restart-Computer cmdlet in PowerShell?
- How to use -For parameter in Restart-Computer cmdlet in PowerShell?
- How to use Group-Object cmdlet in PowerShell?
- How to use the Timeout command in PowerShell?
- How to use ForEach-Object Parallel cmdlet in PowerShell?
- How to use the ErrorAction parameter in PowerShell?
- How to use an alias() for the parameter in PowerShell?
- How to use the -recursive parameter in Get-ChildItem using PowerShell?
- What is the use of the Get-Error cmdlet in PowerShell?
- How to get supported parameters of the cmdlet in PowerShell?
- How to restart a remote system using PowerShell?
- What is Get-ChildItem cmdlet in PowerShell?
- How to restart the Azure VM using Azure CLI in PowerShell?
- What is the use of Passthru parameter in Stop-Process in PowerShell?
- What is the use of -Force parameter in Get-ChildItem in PowerShell?
