- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 –Wait parameter in Restart-Computer cmdlet in PowerShell?
When we use Restart-Computer command with the remote computer names, PowerShell restarts the mentioned remote computers without any checks or validations if the server has come up or not. This requirement is fulfilled with the - Wait parameter. Whenever the - Wait parameter specified,PowerShell performs the below 3 checks on the remote computer when the computer is restarting.This can be noticed in the Progress bar of the PowerShell console.
- PowerShell − If the computer can run the Powershell command on the remote machine.
- WMI − Performs the WMI query on the remote computer using the Win32_ComputerSystem command.
- WINRM − Checks the remote server WINRM connectivity with WS-Management utility.
When you restart two or more computers with Restart-Computer cmdlet by specifying the - Wait command, PowerShell will shoot the restart command on all computers at the same time but checks for the - Wait command will work separately on all of them.
Commands which are written after Reboot-Computer and if specified with - Wait parameter, will be executed in sequence after - Wait parameter check completes. But what if any of the checks fail?
For example, suppose the WINRM service is not running on the server Test1-Win2k12 then the server will be rebooted and comes up but the wait command waits longer and sometimes forever until the WINRM starts on the remote computer. If the service status is automatic then it service will be started automatically but if it is disabled and manual then, the check holds for longer time until manually terminated.
If you want to use the –Wait parameter and want specific check then you can use the –For parameter along with it and if you want the validation to be completed within the time limit then specify the –Timeout parameter.
- How to use -For parameter in Restart-Computer cmdlet in PowerShell?
- How to use –Timeout parameter in Restart-Computer cmdlet in PowerShell?
- How to use Group-Object cmdlet in PowerShell?
- How to use ForEach-Object Parallel cmdlet in PowerShell?
- How to use Wait-Process 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?