# How to use -For parameter in Restart-Computer cmdlet in PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

In the –Wait parameter 3 main checks are validated − PowerShell, WMI, and WINRM connectivity. So whenever you specify the –Wait parameter, you have to wait until all three checks pass, however, if any of the checks fail then script freezes and can not further execute. If you know which specific check you want to perform then you can specify that value with the –For parameter as shown below.

Here, for the example, we will run a single WMI check for the remote server.

Restart-Computer Test1-Win2k12 -Wait -For Wmi -Force

-For parameter must be used with –Wait parameter. Here, again if something goes wrong while validation, it may take longer and longer time for the validation to pass or fail. To prevent the deadlock situation, you can use the -Timeout parameter.

Published on 24-Jul-2020 10:34:27