LoginSignup
1
1

More than 3 years have passed since last update.

Windows Server 2016(またはWindows 10)でのWindows Update設定変更

Last updated at Posted at 2019-07-18

記事の目的

Windows Server 2012(またはWindows 8.1)まではWindows Updateの設定を「更新プログラムを自動的にインストールする」や「更新プログラムを確認しない」等から選ぶことができました。
一方Windows Server 2016(またはWindows 10)以降、上記オプションを選択するUIがなくなりました。UI上から適用を遅らせることはできますが、適用の手動化はできません。
しかしUIから変更できなくなっただけで、設定自体は存在します。
この記事では設定変更の方法を記載します。

注意

以下の手順ではレジストリを変更します。
お決まりの文句ですが、実施前にバックアップを取るなど行ってください。
また、変更は自己責任の下実施してください。

前提

  • Windows Server 2016
  • Windows 10

実施

  1. レジストリエディターを起動します。
  2. 左ツリーで以下のキーに移動します。
    HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU
  3. 左画面でAUOptionsを選択し、右クリックして「修正」を選択します。
  4. 「表記」を10進数にして「値のデータ」に以下から設定したい値を入力し「OK」を押します。
    1: コンピューターの自動更新を無効にします。
    2: ダウンロードおよびインストールを通知します。
    3: 自動的にダウンロードしてインストールを通知します。
    4: 自動的にダウンロードして、スケジュールに従ってインストールします。
  5. レジストリエディターを終了し、サーバーを再起動します。

おまけ

対話形式で設定を変更するPowershellを記載します。
※ 実行はご自身の責任で行ってください。
※ 記法が正しくない、または効率的でない可能性が多分にあります。

function RegSet( $RegPath, $RegKey, $RegKeyType, $RegKeyValue ){
    $Elements = $RegPath -split "\\"
    $BeforeElement = ""
    $RegPath = ""
    $FirstLoop = $True
    $idx = 0
    foreach ($Element in $Elements){
        if($FirstLoop){
            $FirstLoop = $False
        }
        else{
            $RegPath += "\"
        }
        $RegPath += $Element
        if ($idx -gt 1) {
            if(-not (test-path $RegPath)){
                $ParentPath = ""
                for ($idx1 = 0; $idx1 -lt $idx-1; $idx1++) {
                    $ParentPath += $Elements[$idx1]
                    $ParentPath += "\"
                }
                (Get-Item $ParentPath).OpenSubKey($Elements[$idx-1], $true).CreateSubKey($Element)
            }
        }
        $idx += 1
    }

    $Result = Get-ItemProperty $RegPath -name $RegKey -ErrorAction SilentlyContinue

    if( $Result -ne $null ){
        Set-ItemProperty $RegPath -name $RegKey -Value $RegKeyValue
    }
    else{
        New-ItemProperty $RegPath -name $RegKey -PropertyType $RegKeyType -Value $RegKeyValue
    }
    Get-ItemProperty $RegPath -name $RegKey
}

Write-Host "_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/"
Write-Host "_/_/_/ ModifyRegForWindowsUpdate  _/_/_/"
Write-Host "_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/"

$Opt1 = "1: コンピューターの自動更新を無効にします。"
$Opt2 = "2: ダウンロードおよびインストールを通知します。"
$Opt3 = "3: 自動的にダウンロードしてインストールを通知します。"
$Opt4 = "4: 自動的にダウンロードして、スケジュールに従ってインストールします。"

Write-Host
Write-Host $Opt1
Write-Host $Opt2
Write-Host $Opt3
Write-Host $Opt4
Write-Host "-----"

$WUOpt = Read-Host "設定するWindows Updateのオプションを選択してください。(1~4)"

switch($WUOpt)
{
    "1" {Write-Host $Opt1}
    "2" {Write-Host $Opt2}
    "3" {Write-Host $Opt3}
    "4" {Write-Host $Opt4}
    default {
    Write-Host "不正な値が入力されました。: $WUOpt 処理を中断します。"
    Read-Host "終了するには Enterキーを押してください..."
    Exit
    }
}

$Confirm = Read-Host "実行します。よろしいですか? (Y/n)"
if ($Confirm -ne "Y") {
    Write-Host "処理を中断します。"
    Read-Host "終了するには Enterキー を押してください..."
    Exit
}

Write-Host "-----"
try {
    Regset -RegPath "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -RegKey "AUOptions" -RegKeyType "DWord" -RegKeyValue $WUOpt
    Write-Host "処理が終了しました。"
    Write-Host "設定を有効にするためにはWindowsの再起動が必要です。"
} catch {
    Write-Host "エラーが発生しました。"
    Write-Host $Error[0]
}

Read-Host "終了するには Enterキー を押してください..."
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1