![server 2012 r2 remote desktop services pending restart server 2012 r2 remote desktop services pending restart](https://user-images.githubusercontent.com/32651506/141594913-9a652dce-7eb7-454e-b24f-e3e4a5f3a89c.jpg)
- #Server 2012 r2 remote desktop services pending restart install
- #Server 2012 r2 remote desktop services pending restart windows
$util = "\\.\root\ccm\clientsdk:CCM_ClientUtilities" An unexpected restart occurs on the session host server while you're logged on. You start a remote desktop session to the server by using specific user credentials.
#Server 2012 r2 remote desktop services pending restart windows
Invoke-Command -ComputerName $servername -ScriptBlock You have a Remote Desktop Session Host (RD Session Host) on a server that's running Windows Server 2012. So far I have test tested this on Windows 2012, 20 and it seems to work well whether the server has been patched or an application was installed and requires a reboot before installing something new. It uses the Invoke-Command statement to send a few “get” powershell commandlets to a remote server to grab the registry info. I found a simple function for checking that the server has a pending reboot status here and there’s a similar version here too. (Get-CimInstance Win32_OperatingSystem -ComputerName "MyServer01").LastBootUpTime Check for Pending Restart
![server 2012 r2 remote desktop services pending restart server 2012 r2 remote desktop services pending restart](https://www.itingredients.com//wp-content/uploads/2016/04/How-to-Install-RDP-14.png)
Looking into this I found another solution here that uses the Get-CimInstance that returns the correct Date and Time format automatically. Result: Saturday, Aug1:51:02 AM This results in a more readable format and a legit Datetime datatype to work with if needed. $wmi.ConvertToDateTime($wmi.LastBootUpTime) $wmi = Get-WmiObject -Class Win32_OperatingSystem -Computer "MyServer02" Luckily we can assign the object to a variable and use a convert method to get the correct date format. You will notice that the LastBootUpTime results of this powershell command will return something like “20210821015102.496682-240” that needs to be converted. But there’s a catch… (Get-WmiObject -Class Win32_OperatingSystem -Computer "MyServer02").LastBootUpTime Once you have confirmed and selected Restart. Select the Domain Controller for all services, RD Connection Broker, RD Web Access, and RD Session Host. If we encapsulate the command in parenthesis we can use dot notation to get the Last Boot Up Time from its properties. Go to Server Manager Select Add roles and Features, then select Remote Desktop Services Installation. Get-WmiObject -Class Win32_OperatingSystem -Computer "MyServer03" In this example we are invoking the Wind32 Operating System class so we can ask the OS when the last time it was restarted. WMI stands for “ Windows Management Instrumentation” and we can use it to find out when then server was last restarted. The get-wmiobject powershell commandlet provides information such as get, start or stop services as well as things like the OS and BIOS information on a remote machine. Get-Uptime Get-Uptime -Since #last reboot Get-wmiObject and Operating System Info Note: Version 7.0+ now includes a commandlet called Get-Uptime that returns the “the time elapsed since the last boot of the operating system”. These powershell examples will help with checking the last reboot date and time as well as return a Yes and No if it is in need of a restart.
![server 2012 r2 remote desktop services pending restart server 2012 r2 remote desktop services pending restart](https://content.spiceworksstatic.com/service.community/p/post_images/0000003448/52fe3c55/attached_image/RDSVH.jpg)
#Server 2012 r2 remote desktop services pending restart install
If a server is awaiting a reboot before attempting to to install new software or make OS changes.