Microsoft Remote Desktop Restart Computer



-->

Remote Desktop lets me access almost any Windows computer on my network and gives me the feeling of sitting right there in front of the box. A bunch of smart people at Microsoft concocted the Remote Desktop Protocol (RDP), and with the advent of Windows XP, Microsoft began bundling the Remote Desktop Connection (RDC) with ever OS since.

  • How to Enable Remote Reboot Function. Sit behind the computer you want to restart (hereinafter.
  • Local Computer Policy Computer Configuration Administrative Templates Windows Components Remote Desktop Services Remote Desktop Session Host Connections Limit number of connections. In the RD Maximum Connections allowed box, type the maximum number of connections that you want to allow, and then click OK.

Restarts the operating system on local and remote computers.

Syntax

Description

The Restart-Computer cmdlet restarts the operating system on the local and remote computers.

You can use the parameters of Restart-Computer to run the restart operations, to specify theauthentication levels and alternate credentials, to limit the operations that run at the same time,and to force an immediate restart.

Starting in Windows PowerShell 3.0, you can wait for the restart to complete before you run the nextcommand. Specify a waiting time-out and query interval, and wait for particular services to beavailable on the restarted computer. This feature makes it practical to use Restart-Computer inscripts and functions.

Examples

Example 1: Restart the local computer

Restart-Computer restarts the local computer.

Example 2: Restart multiple computers

Restart-Computer can restart remote and local computers. The ComputerName parameter accepts anarray of computer names.

Example 3: Get computer names from a text file

Microsoft Remote Desktop Restart Computer Mac

Restart-Computer gets a list of computer names from a text file and restarts the computers. TheComputerName parameter isn't specified. But because it's the first position parameter, itaccepts the computer names from the text file that are sent down the pipeline.

Get-Content uses the Path parameter to get a list of computer names from a text file,Domain01.txt. The computer names are sent down the pipeline. Restart-Computer restarts eachcomputer.

Example 4: Force restart of computers listed in a text file

This example forces an immediate restart of the computers listed in the Domain01.txt file. Thecomputer names from the text file are stored in a variable. The Force parameter forces animmediate restart.

Get-Content uses the Path parameter to get a list of computer names from a text file,Domain01.txt. The computer names are stored in the variable $Names. Get-Credential promptsyou for a username and password and stores the values in the variable $Creds. Restart-Computeruses the ComputerName and Credential parameters with their variables. The Forceparameter causes an immediate restart of each computer.

Example 6: Restart a remote computer and wait for PowerShell

Restart-Computer restarts the remote computer and then waits up to 5 minutes (300 seconds) forPowerShell to become available on the restarted computer before it continues.

Restart-Computer uses the ComputerName parameter to specify Server01. The Waitparameter waits for the restart to finish. The For specifies that PowerShell can run commands onthe remote computer. The Timeout parameter specifies a five-minute wait. The Delay parameterqueries the remote computer every two seconds to determine whether it's restarted.

Example 7: Restart a computer by using WsmanAuthentication

Restart-Computer restarts the remote computer using the WsmanAuthentication mechanism.Kerberos authentication determines whether the current user has permission to restart the remotecomputer. For more information, seeAuthenticationMechanism.

Restart-Computer uses the ComputerName parameter to specify the remote computer, Server01.The WsmanAuthentication parameter specifies the authentication method as Kerberos.

Parameters

Specifies one computer name or a comma-separated array of computer names. Restart-Computer acceptsComputerName objects from the pipeline or variables.

Type the NetBIOS name, an IP address, or a fully qualified domain name of a remote computer. Tospecify the local computer, type the computer name, a dot ., or localhost.

This parameter doesn't rely on PowerShell remoting. You can use the ComputerName parameter evenif your computer isn't configured to run remote commands.

If the ComputerName parameter isn't specified, Restart-Computer restarts the local computer.

Type:String[]
Aliases:CN, __SERVER, Server, IPAddress
Position:0
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

Prompts you for confirmation before running Restart-Computer.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False

Specifies a user account that has permission to do this action. The default is the current user.

Type a user name, such as User01 or Domain01User01, or enter a PSCredential objectgenerated by the Get-Credential cmdlet. If you type a user name, you're prompted to enter thepassword.

Credentials are stored in a PSCredentialobject and the password is stored as a SecureString.

Note

For more information about SecureString data protection, seeHow secure is SecureString?.

Type:PSCredential
Position:1
Default value:Current user
Accept pipeline input:False
Accept wildcard characters:False

Specifies the frequency of queries, in seconds. PowerShell queries the service specified by theFor parameter to determine whether the service is available after the computer is restarted.

This parameter is valid only together with the Wait and For parameters.

This parameter was introduced in Windows PowerShell 3.0.

If the Delay parameter isn't specified, Restart-Computer uses a five second delay.

Type:Int16
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Specifies the behavior of PowerShell as it waits for the specified service or feature to becomeavailable after the computer restarts. This parameter is only valid with the Wait parameter.

The acceptable values for this parameter are:

  • Default: Waits for PowerShell to restart.
  • PowerShell: Can run commands in a PowerShell remote session on the computer.
  • WMI: Receives a reply to a Win32_ComputerSystem query for the computer.
  • WinRM: Can establish a remote session to the computer by using WS-Management.
Windows 10 remote desktop restart computer

This parameter was introduced in Windows PowerShell 3.0.

Type:WaitForServiceTypes
Accepted values:Wmi, WinRM, PowerShell
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Forces an immediate restart of the computer.

Restart Computer Remote Desktop Connection

Type:SwitchParameter
Aliases:f
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Specifies the duration of the wait, in seconds. When the timeout elapses, Restart-Computer returnsto the command prompt, even if the computers aren't restarted.

The Timeout parameter is only valid with the Wait parameter. Timeout overrides theWait parameter's indefinite waiting period.

This parameter was introduced in Windows PowerShell 3.0.

Type:Int32
Aliases:TimeoutSec
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Restart-Computer suppresses the PowerShell prompt and blocks the pipeline until the computers haverestarted. You can use this parameter in a script to restart computers and then continue to processwhen the restart is finished.

The Wait parameter waits indefinitely for the computers to restart. You can use Timeout toadjust the timing and the For and Delay parameters to wait for particular services to becomeavailable on the restarted computers.

The Wait parameter isn't valid when you're restarting the local computer. If the value of theComputerName parameter contains the names of remote computers and the local computer,Restart-Computer generates a non-terminating error for Wait on the local computer, but waitsfor the remote computers to restart.

This parameter was introduced in Windows PowerShell 3.0.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Shows what would happen if the Restart-Computer runs. The Restart-Computer cmdlet isn't run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False

Specifies the mechanism that is used to authenticate the user credentials. This parameter wasintroduced in Windows PowerShell 3.0.

The acceptable values for this parameter are: Basic, CredSSP, Default, Digest,Kerberos, and Negotiate.

For more information, seeAuthenticationMechanism.

Warning

Credential Security Service Provider (CredSSP) authentication, in which the user credentials arepassed to a remote computer to be authenticated, is designed for commands that requireauthentication on more than one resource, such as accessing a remote network share. This mechanismincreases the security risk of the remote operation. If the remote computer is compromised, thecredentials that are passed to it can be used to control the network session.

Microsoft Remote Desktop Restart Computer
Type:String
Accepted values:Basic, CredSSP, Default, Digest, Kerberos, Negotiate
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Inputs

Restart-Computer accepts computer names from the pipeline or variables.

Outputs

Windows 10 Remote Desktop Restart Computer

Microsoft Remote Desktop Restart Computer

None

Restart-Computer doesn't generate any output.

Notes

  • In Windows, Restart-Computer uses the Win32Shutdown methodof the Windows Management Instrumentation (WMI) Win32_OperatingSystemclass. This method requires the SeShutdownPrivilege privilege be enabled for the user accountused to restart the machine.
  • On Linux and Mac OS, Restart-Computer uses the /sbin/shutdown bash tool.

Related Links

Information in this topic applies to desktop and web applications.

By default the Microsoft Windows operating system includes the Remote Desktop component that allows you to connect to a remote computer and work with it as you work with your local computer.

Using this component you can run and monitor automated tests on remote computers: you can connect to a test computer using a Remote Desktop connection and use the Remote Desktop window to work with the remote computer on your PC. For more information on running automated tests by using the Remote Desktop component, see About Running Tests via Remote Desktop.

While running GUI tests via the Remote Desktop component, keep in mind that the Remote Desktop window must be visible on screen. If you minimize the Remote Desktop window or disconnect from the Remote Desktop Connection session, the GUI tests will fail. To work around this problem, see the Running Tests in Minimized Remote Desktop Windows help topic.

However, sometimes, you may need to follow test running, so you may need to control the remote desktop. In this case, the screen resolution on the remote computer must be the same as on the master computer. Sometimes, it may be inconvenient. To work around this problem, you can specify the settings of the Remote Desktop connection, save them in an external .rdp file, and then use this file to start a Remote Desktop Connection session with the needed settings. Below is a step-by-step instruction on how to do this.

  1. Open Remote Desktop Connection. The way you do this depends on the operating system you use.

  2. Expand the displayed dialog by clicking Show Options.

  3. In the Connection settings group of settings, click Save As to create an .rdp file that will store the Remote Desktop Connection settings.

  4. In the resulting Save As dialog, specify the desired name and path for the created file, and then click Save.

  5. Close the Remote Desktop Connection window.

  6. Open the created .rdp file in any editor of your choice, for example, in Notepad, and add the following string at the end of the file:

    Make sure that the parameters desktopwidth:i:1280 and desktopheight:i:1024 match the server's desktop resolution. You can also change the color settings. For this purpose, replace the value session bpp:i:8 with the session bpp:i:24 string.

  7. Double-click the .rdp file to start a Remote Desktop Connection session.

Remote

After that, you can resize the Remote Desktop window as you wish, at that, the window will show the entire remote desktop. So, you can make the Remote Desktop window smaller and you will be able to control your test remotely.

See Also

Microsoft Remote Desktop Restart Computer

Running Tests via Remote Desktop
About Running Tests via Remote Desktop
Running Tests in Minimized Remote Desktop Windows
Running Tests
Running Tests on Locked Computers