Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check for a pending reboot?

I am trying to get to know where reboot is required or not for a Windows machine. However, my script is throwing and error.

powershell "$key = Get-Item "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" -ErrorAction SilentlyContinue"

Error :
Get-Item : A positional parameter cannot be found that accepts argument
'Update\RebootRequired'.
At line:1 char:8
+ $key = Get-Item
HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Aut ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-Item], ParameterBindin
   gException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell
   .Commands.GetItemCommand

I am running this command in "command prompt". Not sure what it means !

like image 279
Pradeep Shanbhag Avatar asked Dec 18 '17 11:12

Pradeep Shanbhag


1 Answers

Pending reboot can be caused by variety of reasons, not just the ones that are detailed in other answers. Try PendingReboot module, which incorporates various tests into a single cmdlet:

# Install
Install-Module -Name PendingReboot

# Run
Test-PendingReboot -Detailed
like image 93
George Chakhidze Avatar answered Oct 19 '22 20:10

George Chakhidze