Windows PowerShellでIPv6をDisableする

若干 PowerShell に興味を持ち始めたので、何でも PowerShell スクリプトを作って試している。
今回はWindows7IPv6をDisableするスクリプトを作成した。問題点は、レジストリをいじるところ。
また、このスクリプトにはまったくエラー処理や確認処理が入っていない。

Set-ItemPropertyのコマンドに -whatIf をつけると操作内容が確認できるが実行はされないという点が今日の収穫

# <disable-ip6.ps1>
# How to disable IP version 6 (IPv6) or its specific components in Windows 7, in Windows Vista, in Windows Server 2008 R2, and in Windows Server 2008
# <http://support.microsoft.com/kb/929852/en-us>
# 操作対象となるレジストリのパス
$path = "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\"

Set-ItemProperty $path -name "DisabledComponents" -value "0xffffffff"

あとはコマンド プロンプトからこんな感じで実行すればいいのかな

powershell -ExecutionPolicy RemoteSigned -File "C:\Path\disable-ip6.ps1"