この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。
ご機嫌いかがでしょうか、豊崎です。
Windowsの設定を確認しようとした時に、サーバにログインするのが手間だったので、AWS Systems Managerのアクション「Run Command」を利用してWindowsにログインをせずに基本的な設定値を出力してみました。
前提
EC2には「AmazonEC2RoleforSSM」ポリシーがアタッチされたIAMRoleが付与されているものとします。
今回はWindows Server 2012R2とWindows Server 2016のEC2を用意しました。
やってみる
それではAWSマネジメントコンソールからAWS Systems Managerダッシュボードを開き、Run Commandをクリックしていきます。
コマンドの実行をクリックして進んで行きます。
「AWS-RunPowerShellScript」を選択します。
準備しておいた2台のEC2をターゲットとして選択します。
コマンドのパラメータに以下のコマンドをコピペします。
Write-Output "***host name***"
$env:ComputerName
Write-Output ""
Write-Output "***disk***"
Get-Volume | Select-Object DriveLetter,FileSystem,@{Label='FreeSpace';Expression={"{0:N2}GB" -f ($_.SizeRemaining/1GB)}},@{Label='Size';Expression={"{0:N2}GB" -f ($_.Size/1GB)}} | Format-Table
Write-Output ""
Write-Output "***fire wall***"
Get-NetFirewallProfile | Select-Object Name,Enabled | Format-Table
Write-Output ""
Write-Output "***WindowsUpdate***"
$WindowsUpdateAU = Get-ItemProperty -Path registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\"Auto Update"
$WindowsUpdateAU.AUOptions
if($WindowsUpdateAU -ne $null){
Switch($WindowsUpdateAU.AUOptions){
0{$WUAU = "Unconfigured"}
1{$WUAU = "Never check fot updates(not recommended)"}
2{$WUAU = "Download updates but let me choose whether to install them"}
3{$WUAU = "Check for updates but let me choose whether to download and install them"}
4{$WUAU = "Install updates automatically(recommended)"}
$null {$WUAU = "Unconfigured"}
default{$WUAU = "RDP to check the setting"}
}
}
$WUAU
Write-Output ""
Write-Output "***time zone***"
tzutil /g
Write-Output ""
Write-Output "***locale***"
Get-WinSystemLocale | Select-Object Name
あとはデフォルト値で実行をしました。
出力結果としは以下のようになりました。
※どちらのOSも出力形式は同じです。
***host name***
WIN-PMSNTIIXXXX
***disk***
DriveLetter FileSystem FreeSpace Size
----------- ---------- --------- ----
NTFS 0.09GB 0.34GB
C NTFS 9.70GB 29.66GB
***fire wall***
Name Enabled
---- -------
Domain True
Private True
Public True
***WindowsUpdate***
Unconfigured
***time zone***
UTC
***locale***
Name
----
en-US
まとめ
自分で使う用の備忘録的なポストでしたが、Powershellのスクリプトを変えれば何にでも使えるので便利です。誰かのお役に経てば幸いです。
参考
Windows Server の主な設定値を PowerShell で取得して CSV で出力する
PowerShell ストレージ調査に役立つコマンドレットとスクリプト~Get-PhysicalDiskやGet-VirtualDisk