如何检查挂起的重新启动?
我想知道Windows机器需要重启或不重启。但是,我的脚本正在投掷和错误。如何检查挂起的重新启动?
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
我在“命令提示符”中运行此命令。不知道这意味着什么!
基本上,你可以使用Test-Path
,因为只有在挂起重启时才存在该密钥。
Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired"
有几件事情:
-
你的语法不,如果你想从运行CMD PowerShell命令正确,它看起来像这样:
powershell.exe“GET-项目'HKLM:SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ WindowsUpdate \ Auto Update \ RebootRequired'“
至少对我来说,不存在一个名为”RebootRequired“的Item/Key,我只获得有效的Output下一个更高的路径
Get-Item "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update
它提供了键和值保存在注册表项中,但没有密钥“RebootRequired”,你确定这个密钥存在吗?如果你发现一个问题的答案,请张贴的答案,而不是你自己的意见,但它似乎并没有在我的机器上工作...
第3位。应该是问题中的评论。这不是答案的一部分。 – Matt
嘿得到的答案 的PowerShell “(调用-WmiMethod - 命名根\ CCM \ clientsdk -Class CCM_ClientUtilities -Name DetermineIfRebootPending).RebootPending” –
这是完全可以接受的回答你自己的问题,甚至接受它。考虑添加你的评论作为一个正确的答案 - 它可能会在未来帮助其他人。 – David
[C#:如何可以检测到Windows 7需要重新启动]可能重复(https://*.com/questions/15482174/c-how-can-a-required-reboot-be-detected-for-windows -7) – TheIncorrigible1