【发布时间】:2017-12-18 11:53:30
【问题描述】:
我试图了解 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
我在“命令提示符”中运行此命令。不知道是什么意思!
【问题讨论】:
-
嘿,得到了答案 powershell "(Invoke-WmiMethod -Namespace root\ccm\clientsdk -Class CCM_ClientUtilities -Name determineIfRebootPending).RebootPending"
-
回答您自己的问题甚至接受它是完全可以接受的......考虑将您的评论添加为正确的答案 - 它可能会在未来帮助其他人。
标签: powershell installation automation registry