2017-12-18 7 views
-1

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 

"명령 프롬프트"에서이 명령을 실행하고 있습니다. 그것이 무엇을 의미하는지 확실하지 않습니다!

+0

안녕하세요 당신의 자신의 질문에 대답하고 심지어 그것을 받아들이는 완벽하게 허용 –

+1

을 ".RebootPending (호출-WmiMethod -namespace 루트 \ CCM \ clientsdk -Class CCM_ClientUtilities -Name DetermineIfRebootPending)"대답 PowerShell을 얻었다. .. 귀하의 의견을 적절한 답변으로 추가하는 것을 고려해보십시오 - 다른 사람들에게 도움이 될 수 있습니다. – David

+0

가능한 복제본 [C# : Windows 7에서 필요한 재부팅을 검색하는 방법] (https://stackoverflow.com/questions/15482174/c-how-can-a-required-reboot-be-detected-for-windows) -7) – TheIncorrigible1

답변

2

기본적으로 사용할 수있는 Test-Path입니다. 보류중인 재부팅이있는 경우에만 키가 있기 때문입니다.

Test-Path "HKLM:\SOFTWARE­\Microsoft­\Windows­\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" 
1

몇 가지 :

  1. 귀하의 구문은 당신이 cmd를에서 PowerShell 명령을 실행하려면 올바른 아니었다, 그것은 다음과 같이한다 :

    powershell.exe를 "GET-항목 'HKLM : Software \ Microsoft \ Windows \ CurrentVersion \ WindowsUpdate \ Auto Update \ RebootRequired' "

  2. 적어도 나를 위해"RebootRequired "라는 항목/키가 없습니다. 그 다음 높은 경로 Get-Item "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update은 키와 reg 항목에는 값이 저장되지만 "RebootRequired"키는 저장되지 않았습니까?

  3. 당신이 내 컴퓨터에서 작동하지 않지만 질문에 대한 답변은 대신 자신의 의견의 대답으로 게시하시기 바랍니다 발견하면 ...

+1

숫자 3. 질문에 대한 의견이어야합니다. 그것은 대답의 일부가 아닙니다. – Matt

관련 문제