Restart-Computer is a Windows PowerShell command that allows you to restart a computer remotely or locally. This command is useful for restarting a computer after making changes to its configuration, such as installing software or updating drivers. It can also be used to restart a computer that is not responding or has become unresponsive. In this article, we will explore the syntax, parameters, inputs, outputs, examples, and tips for using the Restart-Computer command.
Syntax
The syntax for the Restart-Computer command is as follows:
Restart-Computer [-ComputerName]
Parameters
The parameters for the Restart-Computer command are as follows:
Parameter | Description |
---|---|
-ComputerName | Specifies the computer to restart. This parameter is required. |
-Credential | Specifies a user account that has permission to restart the computer. This parameter is optional. |
-Delay | Specifies the number of seconds to wait before restarting the computer. This parameter is optional. |
-Force | Specifies that the computer should be restarted even if there are open files or applications. This parameter is optional. |
-ForcedShutdown | Specifies that the computer should be restarted immediately, without giving users a chance to save their work. This parameter is optional. |
-Reboot | Specifies that the computer should be restarted. This parameter is optional. |
-Wait | Specifies that the command should wait for the computer to restart before it returns. This parameter is optional. |
-WhatIf | Specifies that the command should simulate the actions that it would take without actually performing them. This parameter is optional. |
-Confirm | Specifies that the command should prompt the user for confirmation before performing the action. This parameter is optional. |
Inputs
The Restart-Computer command requires a computer name as its input. This can be a local computer name or a remote computer name. The command also accepts a credential parameter, which is used to authenticate the user on the remote computer.
Outputs
The Restart-Computer command does not have any outputs. It simply restarts the specified computer.
Examples
The following example restarts the local computer:
Restart-Computer
The following example restarts a remote computer named “Server1”:
Restart-Computer -ComputerName Server1
The following example restarts a remote computer named “Server1” with a delay of 30 seconds:
Restart-Computer -ComputerName Server1 -Delay 30
Tips
When using the Restart-Computer command, there are a few tips to keep in mind:
- Make sure that you have the necessary permissions to restart the computer.
- If you are restarting a remote computer, make sure that you specify the correct credentials.
- If you are restarting a computer that is not responding, use the -Force parameter to force the restart.
- If you are restarting a computer that has open files or applications, use the -ForcedShutdown parameter to force the restart.
- If you want to simulate the command without actually performing it, use the -WhatIf parameter.
- If you want to be prompted for confirmation before performing the action, use the -Confirm parameter.
Conclusion
The Restart-Computer command is a useful tool for restarting a computer remotely or locally. It can be used to restart a computer after making changes to its configuration, such as installing software or updating drivers. It can also be used to restart a computer that is not responding or has become unresponsive. By using the syntax, parameters, inputs, outputs, examples, and tips outlined in this article, you can easily use the Restart-Computer command to restart a computer.