通常、ユーザーがドライバー、アップデート (ソフトウェアまたはシステム)、またはソフトウェアをインストールした後、または Windows クライアントまたはサーバー マシンで構成を変更した後、システムを再起動するように求められます。この投稿では、その方法の手順を説明します。Windows コンピュータで保留中の再起動を確認する。
Windows コンピュータで保留中の再起動を確認する方法
多くの Windows OS タスクの完了時に、コンピュータの再起動が必要になる場合があります。ログインしていてアクティブなセッション中に、ポップアップ ボックスまたは通知によって再起動が保留中であるか、再起動が必要であることが通知されます。これを閉じるか、受け入れて Windows を再起動することができます。ただし、マシンをすぐに再起動したくない、またはすぐに再起動できない状況もあります。たとえば、再起動する前に完了する必要がある未完了の作業がある場合や、運用サーバーに更新プログラムをインストールしたばかりで、そのサーバーが再起動できる場合などです。すぐに再起動しないでください。
このようなシナリオでは、特に後者に関する場合、再起動のことを忘れて、後でいくつかのサーバーまたはクライアント マシンを再起動する必要があることに気づくかもしれませんが、どのマシンを再起動する必要があるのかを特定できなくなります。この状況では、 Windows コンピュータで保留中の再起動を確認するには、パワーシェルスクリプト。
現在、再起動が保留中の場合、Windows は、次の表に示すように、関連付けられた値と条件とともに、次のレジストリの場所にそのことを示すいくつかのレジストリ値またはフラグを追加します。
鍵 | 価値 | 状態 |
HKLM:\SOFTWARE\Microsoft\Updates | UpdateExeVolatile | 値は0以外です |
HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager | 保留中のファイル名の変更操作 | 値が存在する |
HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager | PendingFileRenameOperations2 | 値が存在する |
HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired | それ | キーが存在します |
HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Services\Pending | それ | GUID サブキーが存在する |
HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\PostRebootReporting | それ | キーが存在します |
HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce | DVD再起動信号 | 値が存在する |
HKLM:\ソフトウェア\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending | それ | キーが存在します |
HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootInProgress | それ | キーが存在します |
HKLM:\ソフトウェア\Microsoft\Windows\CurrentVersion\Component Based Servicing\PackagesPending | それ | キーが存在します |
HKLM:\SOFTWARE\Microsoft\ServerManager\CurrentRebootAttempts | それ | キーが存在します |
HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon | ドメインに参加する | 値が存在する |
HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon | SpnSetを避ける | 値が存在する |
HKLM:\SYSTEM\CurrentControlSet\Control\コンピュータ名\アクティブコンピュータ名 | コンピュータ名 | HKLM:\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName の値 ComputerName が異なります |
関連するレジストリ パスを特定したため、1 つのレジストリ パスを確認し忘れたり、どれを確認するかを忘れたりする可能性があるため、手動でレジストリをくまなく調べる代わりに、次のことができます。作成して実行する以下のコードを使用した Check-PendingReboot.ps1 スクリプト。上記の表にあるすべてのレジストリ キーをチェックするタスクを自動化します。
[CmdletBinding()] param( [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string[]]$ComputerName, [Parameter()] [ValidateNotNullOrEmpty()] [pscredential]$Credential )
$ErrorActionPreference = 'Stop'
$scriptBlock = {
$VerbosePreference = $using:VerbosePreference function Test-RegistryKey { [OutputType('bool')] [CmdletBinding()] param ( [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string]$Key ) $ErrorActionPreference = 'Stop'
if (Get-Item -Path $Key -ErrorAction Ignore) { $true } }
function Test-RegistryValue { [OutputType('bool')] [CmdletBinding()] param ( [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string]$Key,
[Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string]$Value ) $ErrorActionPreference = 'Stop'
if (Get-ItemProperty -Path $Key -Name $Value -ErrorAction Ignore) { $true } }
function Test-RegistryValueNotNull { [OutputType('bool')] [CmdletBinding()] param ( [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string]$Key,
[Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string]$Value ) $ErrorActionPreference = 'Stop'
if (($regVal = Get-ItemProperty -Path $Key -Name $Value -ErrorAction Ignore) -and $regVal.($Value)) { $true } }
# Added "test-path" to each test that did not leverage a custom function from above since # an exception is thrown when Get-ItemProperty or Get-ChildItem are passed a nonexistant key path $tests = @( { Test-RegistryKey -Key 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending' } { Test-RegistryKey -Key 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootInProgress' } { Test-RegistryKey -Key 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired' } { Test-RegistryKey -Key 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\PackagesPending' } { Test-RegistryKey -Key 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\PostRebootReporting' } { Test-RegistryValueNotNull -Key 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' -Value 'PendingFileRenameOperations' } { Test-RegistryValueNotNull -Key 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' -Value 'PendingFileRenameOperations2' } { # Added test to check first if key exists, using "ErrorAction ignore" will incorrectly return $true 'HKLM:\SOFTWARE\Microsoft\Updates' | Where-Object { test-path $_ -PathType Container } | ForEach-Object { (Get-ItemProperty -Path $_ -Name 'UpdateExeVolatile' | Select-Object -ExpandProperty UpdateExeVolatile) -ne 0 } } { Test-RegistryValue -Key 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce' -Value 'DVDRebootSignal' } { Test-RegistryKey -Key 'HKLM:\SOFTWARE\Microsoft\ServerManager\CurrentRebootAttemps' } { Test-RegistryValue -Key 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon' -Value 'JoinDomain' } { Test-RegistryValue -Key 'HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon' -Value 'AvoidSpnSet' } { # Added test to check first if keys exists, if not each group will return $Null # May need to evaluate what it means if one or both of these keys do not exist ( 'HKLM:\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName' | Where-Object { test-path $_ } | %{ (Get-ItemProperty -Path $_ ).ComputerName } ) -ne ( 'HKLM:\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName' | Where-Object { Test-Path $_ } | %{ (Get-ItemProperty -Path $_ ).ComputerName } ) } { # Added test to check first if key exists 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Services\Pending' | Where-Object { (Test-Path $_) -and (Get-ChildItem -Path $_) } | ForEach-Object { $true } } )
foreach ($test in $tests) { Write-Verbose "Running scriptblock: [$($test.ToString())]" if (& $test) { $true break } } }
foreach ($computer in $ComputerName) { try { $connParams = @{ 'ComputerName' = $computer } if ($PSBoundParameters.ContainsKey('Credential')) { $connParams.Credential = $Credential }
$output = @{ ComputerName = $computer IsPendingReboot = $false }
$psRemotingSession = New-PSSession @connParams if (-not ($output.IsPendingReboot = Invoke-Command -Session $psRemotingSession -ScriptBlock $scriptBlock)) { $output.IsPendingReboot = $false } [pscustomobject]$output } catch { Write-Error -Message $_.Exception.Message } finally { if (Get-Variable -Name 'psRemotingSession' -ErrorAction Ignore) { $psRemotingSession | Remove-PSSession } } }
サーバーは必要なだけ提供できます。コンピュータ名返されるスクリプト内のパラメータ真実または間違いサーバー名と一緒に。次のようなスクリプトを実行して、次のことを確認します。PowerShell リモート処理がセットアップされ、サーバー上で利用可能になります。
PS51> .\Test-PendingReboot.ps1 -Server SRV1,SRV2,SRV3,etc
読む:タスク スケジューラで PowerShell スクリプトをスケジュールする方法
PowerShell スクリプトを使用すると、ドメイン内の 1 つまたはすべてのコンピューターをクエリしたり、サーバー名を手動で指定して再起動を保留しているコンピューターを特定したりできます。特定したら、すぐにマシンを再起動することも、後で再起動するリストを作成することもできます。
今すぐ読んでください:PowerShell を使用して Windows コンピューターをリモート再起動する方法
Windows の再起動が保留中とはどういう意味ですか?
一般に、保留中の再起動要求は、プログラムまたはインストールによってファイル、レジストリ キー、サービス、またはオペレーティング システムの設定が変更され、システムが一時的な状態になる可能性がある場合に発生します。を取得した場合には、保留中の再起動が検出されましたこの通知は、マシン上で更新が保留中であり、追加の更新をインストールする前に再起動を実行する必要があることを示しているだけです。
読む:
レジストリで保留中の再起動を確認するにはどうすればよいですか?
これは次の方法で行うことができますWindows レジストリの検索のために再起動が必要です鍵。この投稿の上の表では、保留中の再起動レジストリ キーに関連するレジストリの場所を特定しました。 Windows 更新プログラムのインストールを完了するために PC の再起動が必要なときに通知を表示したい場合は、始める>設定>アップデートとセキュリティ>Windows アップデート>詳細オプション。ボタンをオンまたはオフに切り替えます。アップデートを完了するために PC の再起動が必要な場合に通知を表示するオプション。
こちらもお読みください:保留中のシステム修復があり、完了するには再起動が必要です。