Windows PowerShell Part4

このエントリーをはてなブックマークに追加
274名無し~3.EXE
Export-WindowsImage の圧縮形式で recovery は含まれてないようです (KeyNotFoundException発生)
http://toro.2ch.net/test/read.cgi/win/1382263043/601 を取り入れて書き直し

# ユーザー設定
$restore="F:\Restore" # 回復イメージ保存先
$mountpoint="F:\mount" # イメージファイルのマウント先
$package="F:\Download\system\OS\Windows 8.1\update 1" # 適用する Update 1(KB2919355) のパス
$cpu="x86" # cpuが32bit(x86)か64bit(x64)か

$imgwin="C:\ESD\Windows\sources\install.wim"
$imgesd="C:\ESD\Windows\sources\install.esd"
if (test-path $imgwin) {
if (test-path $mountpoint) {Remove-Item $mountpoint -recurse -force}
New-Item $mountpoint -type directory
Mount-WindowsImage -ImagePath $imgwin -Index 1 -Path $mountpoint
"2919442","2919355","2932046","2937592","2938439","2934018" | % {
Add-WindowsPackage -Path $mountpoint -PackagePath ("{0}\Windows8.1-KB{1}-{2}.msu" -f $package,$_,$cpu) }
Dismount-WindowsImage -Path $mountpoint -Save
dism /Export-Image /SourceImageFile:"$imgwin" /SourceIndex:1 /DestinationImageFile:"$imgesd" /Compress:recovery
} else {
if (test-path $restore) {Remove-Item $restore -recurse -force}
New-Item $restore -type directory
Expand-WindowsImage -ImagePath $imgesd -Index 1 -ApplyPath $restore
"2919442","2919355","2932046","2937592","2938439","2934018" | % {
Add-WindowsPackage -Path $restore -PackagePath ("{0}\Windows8.1-KB{1}-{2}.msu" -f $package,$_,$cpu) }
New-WindowsImage -ImagePath $imgwin -CapturePath $restore -CompressionType "maximum" -Name "install"
dism /Export-Image /SourceImageFile:"$imgwin" /SourceIndex:1 /DestinationImageFile:"$imgesd" /Compress:recovery
Remove-Item $restore -recurse -force
}
exit