次の方法で共有


IoT Enterprise インストール メディアを更新する

この記事では、メディア更新環境を設定し、WinPE 環境とメイン オペレーティング システムの両方を更新するために必要なすべての前提条件を収集して、ドライバーをインストールします

メディア サービス環境を準備する

  1. 管理者特権で PowerShell を開始します。
    この PowerShell のインスタンスは、更新プログラムを適用するためにインストール メディアにサービスを提供するエンド ツー エンド プロセスに使用し、必要に応じて、Windows インストール メディアの一部ではない必要なドライバーを組み込みます

    • [スタート] を選択します
    • 「PowerShell」と入力します
    • Windows PowerShell を右クリックします
    • [管理者として実行] を選択します
  2. メディア サービス中にファイルを格納するフォルダーを作成する
    PowerShell コマンド New_Item を使用して、メディア サービス中に必要なファイルを格納する次のフォルダーをテクニシャン PC 上で作成します。

    c:\MediaRefresh: メディア サービス中にファイルを格納するための親フォルダー。
    c:\MediaRefresh\Out: サービス中に更新された元のメディアのコピー。
    c:\MediaRefresh\Packages\LCU: 最新の累積的な更新プログラム c:\MediaRefresh\Packages\SSU: 必要に応じたサービス スタック更新プログラム
    c:\MediaRefresh\Drivers: サード パーティ製ドライバー。
    c:\MediaRefresh\Scripts: カスタム インストール スクリプト。 c:\MediaRefresh\WIM: boot.wim と install.wim を更新するための作業ディレクトリ

    md c:\MediaRefresh\Drivers
    md c:\MediaRefresh\Out
    md c:\MediaRefresh\Packages\LCU
    md c:\MediaRefresh\Packages\SSU
    md c:\MediaRefresh\Scripts
    md c:\MediaRefresh\WIM
    
  3. 元のメディアからファイルをコピーする
    元のインストール メディアから c:\MediaRefresh\Out にすべてのファイルをコピーします。

    1. 物理メディアがある場合は手順 b. に進みます。それ以外の場合は、最初に Mount-DiskImage を使用して Windows IoT Enterprise インストール ISO をマウントし、Get-Volume を使用してマウントされたドライブ文字を表示する必要があります。

      Mount-DiskImage -ImagePath <ISO Path> | Get-Volume
      

      <ISO Path> は、ISO に対する完全修飾パスです

      次の手順で使用する必要があるため、DriveLetter をメモします。

    2. <DriveLetter> を使用して c:\MediaRefresh\Out でここに示されている元のインストール メディアから フォルダーにファイルをコピーします。

      robocopy <DriveLetter>:\ c:\MediaRefresh\Out /Copy:DT /e
      

      <DriveLetter> は、マウントされた ISO ファイルに関連付けられているドライブ文字です

    3. c:\MediaRefresh\Out\Sources を使用して、boot.wim と install.wim を c:\MediaRefresh\WIM から フォルダー (WIM ファイルを更新するための作業フォルダー) に移動します。

      robocopy c:\mediarefresh\out\sources c:\MediaRefresh\WIM *.wim /Mov
      
    4. 前のコマンドの ISO をマウントしていない場合は、次の手順に進みます。それ以外の場合は、最初に Dismount-Diskimage を使用して Windows IoT Enterprise インストール ISO のマウントを解除する必要があります

      Dismount-DiskImage -ImagePath <ISO Path>  
      

      <ISO Path> は、ISO ファイルに対する完全修飾パスです。

  4. サービス パッケージを収集する

    最新の累積的な Microsoft サービス更新プログラム (MSU) ファイルを c:\MediaRefresh\Packages\LCU フォルダーにダウンロードします。

    サービス スタック更新プログラム (MSU) の依存関係が必要な場合は、c:\MediaRefresh\Packages\SSU フォルダーにダウンロードします。 次の表は、特定のバージョンの Windows IoT Enterprise の更新プログラムを見つけるのに役立ちます。

    リリース バージョン 更新履歴 更新プログラム カタログ
    Windows 11 IoT Enterprise LTSC 2024 [24H2] 26100 更新履歴を表示する x64 更新プログラムを表示する
    ARM64 更新プログラムを表示する
    Windows 10 IoT Enterprise LTSC 2021 19044 更新履歴を表示する x64 更新プログラムを表示する
    ARM64 更新プログラムを表示する
    Windows 10 IoT Enterprise LTSC 2019 17763 更新履歴を表示する x64 更新プログラムを表示する
    ARM64 更新プログラムを表示する
    Windows 10 IoT Enterprise LTSC 2016 14393 更新履歴を表示する x64 更新プログラムを表示する
    x86 更新プログラムを表示する
    Windows 10 IoT Enterprise LTSC 2015 10240 更新履歴を表示する x64 更新プログラムを表示する
    x86 更新プログラムを表示する
  5. [省略可能] サード パーティ製ドライバーを収集する
    デバイスに必要なサード パーティ製ドライバーを非圧縮形式で c:/MediaRefresh/drivers フォルダーのルートまたは c:/MediaRefresh/drivers へのサブフォルダーとして配置します。

  6. [省略可能] 構成スクリプトを収集する
    Windows セットアップ プロセスの実行中または後に実行される Setupcomplete.cmd および ErrorHandler.cmd カスタム スクリプトを c:\MediaRefresh\Scripts フォルダーに配置します。

    詳細については、「カスタム スクリプトを Windows セットアップに追加する」を参照してください

Windows プレインストール環境 (WinPE) を更新する

Windows プレインストール環境 (WinPE) は、元のインストール メディアの boot.wim フォルダーの下にある \sources の中に含まれています。 このセクションでは、boot.wimを使用して、最新の累積的なサービス更新プログラムで を更新し、必要に応じて WinPE 環境にサード パーティ製ドライバーを組み込むプロセスについて説明します。

  1. WinPE boot.wim をマウントする

    1. WinPE 環境を更新する最初の手順は、PowerShell コマンド mounted を使用して、c:\mediarefresh の下に という名前で一時フォルダーを作成することです

      MD c:\MediaRefresh\mounted
      
    2. boot.wim を更新する前に、ファイル属性が ReadOnly に設定されていないことを確認する必要があります。 PowerShell コマンド Set-ItemProperty を使用して、ReadOnly 属性を削除します。

      Set-ItemProperty -Path "c:\mediarefresh\wim\boot.wim" -Name IsReadOnly -Value $false
      
    3. これで、PowerShell コマンド boot.wim を使用して、インデックス 2 の に格納されている WinPE イメージをマウントできるようになりました

      Mount-WindowsImage -ImagePath "c:\mediarefresh\wim\boot.wim" -Index 2 -Path "c:\mediarefresh\Mounted"
      
    4. インデックス 2 の boot.wim に格納されている WinPE イメージの内容を、c:\mediarefresh\mounted で表示できるようになりました。

  2. WinPE にサード パーティ製ドライバーを適用する
    PowerShell コマンド c:\mediarefresh\drivers を使用して、c:\mediarefresh\mounted フォルダーに収集したサード パーティ製ドライバーを の WinPE にインストールします。

    Note

    テスト目的で、-ForceUnsigned を使用して署名されていないドライバーを追加し、ドライバーにデジタル署名が必要であるという要件をオーバーライドできます。 ドライバーの署名要件の詳細については、デバイス ドライバーと展開の概要に関するページを参照してください。

    Add-WindowsDriver -Path "c:\mediarefresh\Mounted" -Driver "c:\mediarefresh\drivers" -Recurse
    
  3. WinPE にサービス更新プログラムを適用する
    PowerShell コマンド c:\mediarefresh\packages を使用して、c:\mediarefresh\mounted フォルダーにダウンロードした最新の累積的な更新プログラムとその依存関係を の WinPE に適用します。 このプロセスは完了するまで数分かかりますが、Windows イメージに最新のサービス更新プログラムが既に適用されていることを確認します。

    1. まず、サービス スタック更新プログラムの依存関係を適用します。

      Add-WindowsPackage -Path "c:\mediarefresh\mounted" -PackagePath "c:\mediarefresh\packages\SSU"
      
    2. ここで最新の累積的な更新プログラムを適用します。

      Add-WindowsPackage -Path "c:\mediarefresh\mounted" -PackagePath "c:\mediarefresh\packages\LCU"
      

    ヒント

    エラー 0x800f0823 が発生した場合、サービス更新プログラムには、最初に適用する必要がある依存関係がある可能性があります。 依存関係を既にダウンロードしている場合は、前の Add-WindowsPackage をもう一度実行してみてください。 これで問題が解決しない場合は、更新プログラムの別の前提条件をダウンロードする必要がある場合があります。

    • c:\mediarefresh\packages にある更新プログラムのファイル名に記載されている KB####### を書き留めます。
    • support.microsoft.com で KB####### を検索します
    • 一致する最初のトピックを開き、"前提条件" という用語を検索します。
    • 前述の前提条件をダウンロードし、前の Add-WindowsPackage コマンドをもう一度実行します。 前提条件を最初に適用するには、コマンドを 2 回実行する必要がある場合があります。
    • エラーが解決されたら、次の手順に進みます。
  4. 更新された setup.exesetuphost.exec:\mediarefresh\mounted\sources の WinPE から、Robocopy を使用して c:\mediarefresh\out\sources にコピーする前に、更新された Setup.exesetuphost.exe をコピーします。

    1. 最初に、PowerShell コマンド Set-ItemProperty を使用して、c:\mediarefresh\mounted\sources\setup.exe および c:\mediarefresh\mounted\sources\setuphost.exe の ReadOnly 属性を削除する必要があります。

      Set-ItemProperty -Path "c:\mediarefresh\out\sources\setup.exe" -Name IsReadOnly -Value $false
      Set-ItemProperty -Path "c:\mediarefresh\out\sources\setuphost.exe" -Name IsReadOnly -Value $false
      
    2. Robocopyを使用して、setup.exesetuphost.exec:\mediarefresh\mounted\sources から c:\mediarefresh\out\sources にコピーできるようになりました。

      robocopy c:\mediarefresh\mounted\sources c:\mediarefresh\out\sources setup.exe
      robocopy c:\mediarefresh\mounted\sources c:\mediarefresh\out\sources setuphost.exe
      
  5. マウントを解除して WinPE への変更を保存する

    サービス プロセスを完了するには、PowerShell コマンド Dismount-WindowsImage を使用して変更を保存します。

    重要

    Dismount-WindowsImage コマンドを実行する前に、c:\mediarefresh\mountedの下にコンテンツを表示するエクスプローラー ビューまたはコマンド ウィンドウがないことを確認します。 これを行わないと、マウント解除しようとするとエラーが発生します。

    Dismount-WindowsImage -path "c:\mediarefresh\mounted" -save
    
  6. 一時フォルダーを削除する

    boot.wim のマウントが正常に解除されたら、PowerShell コマンド c:\mediarefresh\mounted を使用して一時フォルダー を削除できるようになります

    RD c:\MediaRefresh\mounted
    
  7. Boot.wim フォルダーに out を公開する

    次に、boot.wim を使用して更新された c:\mediarefresh\wimc:\mediarefresh\out\sources から にコピーします。

    robocopy c:\mediarefresh\wim c:\mediarefresh\out\sources boot.wim
    

boot.wim の下に setup.exe および c:\mediarefresh\out\sources\ として格納されている Windows プレインストール環境 (WinPE) が完全に更新されます。

Windows IoT Enterprise を更新する

Windows IoT Enterprise イメージは、install.wim フォルダーの下にある元のインストール メディアの \sources に含まれています。 「メディア サービス環境の準備」セクションで、install.wim を作業フォルダーに移動しました。 このセクションでは、install.wimを使用して、最新の累積的なサービス更新プログラムで を更新し、ターゲット デバイスで必要とされる場合にサード パーティ製ドライバーを組み込むプロセスについて説明します。 更新が完了したら、FAT32 形式のフラッシュ ドライブにコピーできるように、install.wim をより小さな *.swm ファイルに分割します。

  1. OS install.wim をマウントする

    1. WinPE 環境を更新する最初の手順は、PowerShell コマンド mounted を使用して、c:\mediarefresh の下に という名前で一時フォルダーを作成することです。

      MD c:\MediaRefresh\mounted
      
    2. install.wim を更新する前に、ファイル属性が ReadOnly に設定されていないことを確認する必要があります。 PowerShell コマンド Set-ItemProperty を使用して、ReadOnly 属性を削除します。

      Set-ItemProperty -Path "c:\mediarefresh\wim\install.wim" -Name IsReadOnly -Value $false
      
    3. PowerShell コマンド Mount-WindowsImage を使用して、インデックス 2 の install.wim に格納されている Windows IoT Enterprise イメージをマウントできるようになりました

      Mount-WindowsImage -ImagePath "c:\mediarefresh\wim\install.wim" -Index 2 -Path "c:\mediarefresh\Mounted"
      
    4. インデックス 2 の install.wim に格納されている Windows IoT Enterprise イメージのコンテンツは、c:\mediarefresh\mounted で表示できるようになりました。

  2. サード パーティ製ドライバーをインストールする
    PowerShell コマンド c:\mediarefresh\drivers を使用して、c:\mediarefresh\mounted フォルダーに収集したサード パーティ製ドライバーを の OS イメージにインストールします。 -recurse パラメーターを使用すると、サブフォルダーの処理が可能になります。

    Add-WindowsDriver -Path "c:\mediarefresh\mounted" -Driver "c:\mediarefresh\drivers" -Recurse 
    

    Note

    テスト目的で、-ForceUnsigned を使用して署名されていないドライバーを追加し、ドライバーにデジタル署名が必要であるという要件をオーバーライドできます。 ドライバーの署名要件の詳細については、デバイス ドライバーと展開の概要に関するページを参照してください。

  3. カスタム セットアップ スクリプトを追加する

    1. OS イメージにカスタム セットアップ スクリプトを追加する前に、まず PowerShell コマンド scripts を使用して c:\mediarefresh\mounted\windows\setup\ の下に フォルダーを作成します。

      MD c:\mediarefresh\mounted\windows\setup\scripts
      
    2. c:\mediarefresh\scripts を使用してスクリプトを c:\mediarefresh\mounted\windows\setup\scripts から にコピーします。

      robocopy c:\mediarefresh\scripts c:\mediarefresh\mounted\windows\setup\scripts *.cmd
      
  4. サービス パッケージを OS イメージに適用する
    PowerShell コマンド c:\mediarefresh\packages を使用して、c:\mediarefresh\mounted フォルダーにダウンロードした最新の累積的な更新プログラムとその依存関係を の WinPE に適用します。

    1. まず、サービス スタック更新プログラムの依存関係を適用します。

      Add-WindowsPackage -Path "c:\mediarefresh\mounted" -PackagePath "c:\mediarefresh\packages\SSU"
      
    2. ここで最新の累積的な更新プログラムを適用します。

      Add-WindowsPackage -Path "c:\mediarefresh\mounted" -PackagePath "c:\mediarefresh\packages\LCU"
      

    ヒント

    エラー 0x800f0823 が発生した場合、サービス更新プログラムには、最初に適用する必要がある依存関係がある可能性があります。 依存関係を既にダウンロードしている場合は、前の Add-WindowsPackage コマンドをもう一度実行してみてください。 これで問題が解決しない場合は、更新プログラムの別の前提条件をダウンロードする必要がある場合があります。

    • c:\mediarefresh\packages にある更新プログラムのファイル名に記載されている KB####### を書き留めます。
    • support.microsoft.com で KB####### を検索します
    • 一致する最初のトピックを開き、"前提条件" という用語を検索します。
    • 記載されている前提条件をダウンロードし、上記のコマンドをもう一度実行します。 前提条件を最初に適用するには、コマンドを 2 回実行する必要がある場合があります。
    • エラーが解決されたら、次の手順に進みます。
  5. 更新された install.wim を保存してマウントを解除する
    サービス プロセスを完了するには、PowerShell コマンド Dismount-WindowsImage を使用して変更を保存します。

    重要

    Dismount-WindowsImage コマンドを実行する前に、c:\mediarefresh\mountedの下にコンテンツを表示するエクスプローラー ビューまたはコマンド ウィンドウがないことを確認します。 これを行わないと、マウント解除しようとするとエラーが発生します。

    Dismount-WindowsImage -path "c:\mediarefresh\mounted" -save
    
  6. 一時フォルダー mounted を削除する
    boot.wim のマウントが正常に解除されたら、PowerShell コマンド c:\mediarefresh\mounted を使用して一時フォルダー を削除できるようになります

    RD c:\mediarefresh\mounted
    
  7. FAT32 ファイル システムをサポートする WIM を分割する
    新しい install.wim が FAT32 形式のフラッシュ メディアに収まるようにするには、最大ファイル サイズが 4 GB である場合は、Split-WindowsImage PowerShell コマンドを使用して、Windows イメージ (install.wim) ファイルを最大サイズ 4,000 MB の小さい (.swm) ファイルのセットに分割します。 その結果生成される *.swm ファイルは c:\mediarefresh\out\sources フォルダーに書き込まれます。

    Split-WindowsImage -ImagePath "c:\mediarefresh\wim\install.wim" -SplitImagePath "c:\mediarefresh\out\sources\install.swm" -FileSize 4000 -CheckIntegrity
    

OS のインストール イメージ (最初は install.wim のように保存される) は、c:\mediarefresh\out\sources\ の下に install.swminstall2.swm として保存され、元の install.wim であるかのように使用されます。

更新されたメディアをフラッシュ ドライブにコピーする

起動可能なフラッシュ ドライブを作成していない場合は、「フラッシュ ドライブから Windows をインストールする」の手順に従って作成してから続行してください。

更新されたインストール メディアを作成する最後の手順は、c:\mediarefresh\out を使用して起動可能なフラッシュ ドライブに の内容をコピーすることです。

robocopy c:\mediarefresh\out <DriveLetter>:\ /e

<DriveLetter> はフラッシュ ドライブに関連付けられているドライブ文字です

新しいデバイスに Windows をインストールする

  1. フラッシュ ドライブをターゲット デバイスに接続します。

  2. デバイスの電源を入れ、Esc/F10/F12キーなど、コンピューターの起動デバイス選択メニューを開くキーを押します。 フラッシュドライブからデバイスを起動するオプションを選択します。

    Windows セットアップが開始されます。 指示に従って Windows をインストールします。

    ヒント

    場合によっては、デバイスの製造元の指示に従って、このプロセスがデバイスで動作しないフラッシュ ドライブから起動するように構成する必要があります。

  3. セットアップの初期フェーズが完了し、デバイスが再起動すると、セットアップが再び最初から開始される場合があります。 セットアップが再び開始された場合は、セットアップを取り消し、コンピューターをシャットダウンしてからフラッシュ ドライブを取り出し、デバイスの電源をオンにしてセットアップの次のフェーズに進みます。

    ヒント

    何らかの理由でセットアップ プロセス中にエラーが発生した場合は、トラブルシューティング ガイダンスに関する次の記事を参照してください。

完全なスクリプト

このセクションには、メディア サービスの各手順を自動的に連続して実行する完全なスクリプトが含まれています。 このスクリプトを使用する前に、この記事の「メディア サービス環境を準備する」セクションを完了する必要があります。 準備ができたら、次の PowerShell スクリプトを c:\mediarefresh\mediarefresh.ps1. にコピーします

$LogFile = ".\MediaRefresh.log"
$LogDetail = ".\MediaRefreshDetail.log"

"================================================" >> $LogFile
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " | Starting MediaRefresh" >> $LogFile
"================================================" >> $LogFile
Write-Host "Updating Boot.wim" -ForegroundColor Blue
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " | Boot.wim Update Started" >> $LogFile
Write-Host "     Preparing to mount boot.wim" -ForegroundColor Blue

(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Checking for existing .\Mounted folder" >> $LogFile

if ( -not (Test-Path -Path 'c:\MediaRefresh\mounted' -PathType Container)) { 
   (get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Create .\Mounted folder" >> $LogFile
   MD c:\MediaRefresh\mounted >> $LogDetail
   (get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Created .\Mounted folder" >> $LogFile
   }
   else {
   (get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     .\Mounted folder already existed" >> $LogFile 
   }

Write-Host "     Setting boot.wim file attributes to read-write" -ForegroundColor Blue
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Setting boot.wim file attributes to read-write" >> $LogFile
Set-ItemProperty -Path "c:\mediarefresh\wim\boot.wim" -Name IsReadOnly -Value $false | out-null
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Set boot.wim file attributes to read-write" >> $LogFile

Write-Host "     Mounting boot.wim" -ForegroundColor Blue
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Mount-WindowsImage boot.wim Started" >> $LogFile
Mount-WindowsImage -ImagePath "c:\mediarefresh\wim\boot.wim" -Index 2 -Path "c:\mediarefresh\Mounted" >> $LogDetail
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Mount-WindowsImage boot.wim Completed" >> $LogFile

Write-Host "     Installing Drivers" -ForegroundColor Blue
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Add-WindowsDrivers to boot.wim Started" >> $LogFile
Add-WindowsDriver -Path "c:\mediarefresh\mounted" -Driver "c:\mediarefresh\drivers" -Recurse >> $LogDetail
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Add-WindowsDrivers to boot.wim Completed" >> $LogFile

Write-Host "     Installing Servicing Stack Update" -ForegroundColor Blue
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Add-WindowsPackage SSU to boot.wim Started" >> $LogFile
Add-WindowsPackage -Path "c:\mediarefresh\mounted" -PackagePath "c:\mediarefresh\packages\SSU" >> $LogDetail
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Add-WindowsPackage SSU to boot.wim Completed" >> $LogFile

Write-Host "     Installing Latest Cumulative Update" -ForegroundColor Blue
Write-Host "          Note: This process may take several minutes to complete." -ForegroundColor Cyan
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Add-WindowsPackage LCU to boot.wim Started" >> $LogFile
Add-WindowsPackage -Path "c:\mediarefresh\mounted" -PackagePath "c:\mediarefresh\packages\LCU" >> $LogDetail
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Add-WindowsPackage LCU to boot.wim Completed" >> $LogFile

Write-Host "     Setting read-write attribute on \out\sources\setup.exe" -ForegroundColor Blue
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Setting \out\sources\setup.exe file attributes to read-write" >> $LogFile
Set-ItemProperty -Path "c:\mediarefresh\out\sources\setup.exe" -Name IsReadOnly -Value $false >> $LogDetail
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Set \out\sources\setup.exe file attributes to read-write" >> $LogFile

Write-Host "     Copying updated setup.exe to \out\sources" -ForegroundColor Blue
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Copy updated setup.exe to .\out\sources Started" >> $LogFile
robocopy c:\mediarefresh\mounted\sources c:\mediarefresh\out\sources setup.exe | out-null
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Copy updated setup.exe to .\out\sources Completed" >> $LogFile

Write-Host "     Saving and dismounting boot.wim" -ForegroundColor Blue
Write-Host "          Note: This process may take several minutes to complete." -ForegroundColor Cyan
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Dismount-WindowsImage boot.wim Started" >> $LogFile
Dismount-WindowsImage -path "c:\mediarefresh\mounted" -save -CheckIntegrity -LogLevel 3 >> $LogDetail
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Dismount-WindowsImage boot.wim Completed" >> $LogFile

Write-Host "     Removing \Mounted folder" -ForegroundColor Blue
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Removing .\mounted folder" >> $LogFile
RD c:\mediarefresh\mounted | out-null
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     .\mounted folder removed" >> $LogFile

Write-Host "     Copying updated boot.wim to \out\sources" -ForegroundColor Blue
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Copy boot.wim to .\out\sources Started" >> $LogFile
robocopy c:\mediarefresh\wim c:\mediarefresh\out\sources boot.wim | out-null
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Copy boot.wim to .\out\sources Completed" >> $LogFile
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " | Boot.wim Update Completed" >> $LogFile
Write-Host "Updating Boot.wim Complete" -ForegroundColor Blue

Write-Host "Updating Install.wim" -ForegroundColor Blue
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " | Install.wim Update Started" >> $LogFile
Write-Host "     Preparing to mount install.wim" -ForegroundColor Blue

(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Checking for existing .\Mounted folder" >> $LogFile

if ( -not (Test-Path -Path 'c:\MediaRefresh\mounted' -PathType Container)) { 
   (get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Create .\Mounted folder" >> $LogFile
   MD c:\MediaRefresh\mounted  >> $LogDetail
   (get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Created .\Mounted folder" >> $LogFile
   }
   else {
   (get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     .\Mounted folder already existed" >> $LogFile 
   }

Write-Host "     Setting read-write attribute on install.wim" -ForegroundColor Blue
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Setting install.wim file attributes to read-write" >> $LogFile
Set-ItemProperty -Path "c:\mediarefresh\wim\install.wim" -Name IsReadOnly -Value $false | out-null
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Set install.wim file attributes to read-write" >> $LogFile

Write-Host "     Mounting install.wim" -ForegroundColor Blue
Write-Host "          Note: This process may take several minutes to complete." -ForegroundColor Cyan
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Mount-WindowsImage install.wim Started" >> $LogFile
Mount-WindowsImage -ImagePath "c:\mediarefresh\wim\install.wim" -Index 2 -Path "c:\mediarefresh\Mounted" >> $LogDetail
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Mount-WindowsImage install.wim Completed" >> $LogFile


Write-Host "     Installing Drivers" -ForegroundColor Blue
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Add-WindowsDrivers to install.wim Started" >> $LogFile
Add-WindowsDriver -Path "c:\mediarefresh\mounted" -Driver "c:\mediarefresh\drivers" -Recurse  >> $LogDetail
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Add-WindowsDrivers to install.wim Completed" >> $LogFile

Write-Host "     Creating folder \Windows\Setup\Scripts" -ForegroundColor Blue
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Checking for existing \windows\setup\scripts folder" >> $LogFile
if ( -not (Test-Path -Path 'c:\mediarefresh\mounted\windows\setup\scripts' -PathType Container)) {
   (get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Create \windows\setup\scripts folder" >> $LogFile
   MD c:\mediarefresh\mounted\windows\setup\scripts >> $LogDetail
   (get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Created \windows\setup\scripts folder" >> $LogFile
   }
   else {
   (get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     \windows\setup\scripts already existed" >> $LogFile 
   }

Write-Host "     Copying Scripts to \Windows\Setup\Scripts" -ForegroundColor Blue
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Copy scripts to \windows\setup\scripts Started" >> $LogFile
robocopy c:\mediarefresh\scripts c:\mediarefresh\mounted\windows\setup\scripts *.cmd | out-null
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Copy scripts to \windows\setup\scripts Completed" >> $LogFile

Write-Host "     Installing Servicing Stack Update" -ForegroundColor Blue
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Add-WindowsPackage SSU to install.wim Started" >> $LogFile
Add-WindowsPackage -Path "c:\mediarefresh\mounted" -PackagePath "c:\mediarefresh\packages\SSU"  >> $LogDetail
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Add-WindowsPackage SSU to install.wim Completed" >> $LogFile 

Write-Host "     Installing Latest Cumulative Update" -ForegroundColor Blue
Write-Host "          Note: This process may take several minutes to complete." -ForegroundColor Cyan
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Add-WindowsPackage LCU to install.wim Started" >> $LogFile 
Add-WindowsPackage -Path "c:\mediarefresh\mounted" -PackagePath "c:\mediarefresh\packages\LCU" >> $LogDetail
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Add-WindowsPackage LCU to install.wim Completed" >> $LogFile 

Write-Host "     Saving and dismounting install.wim" -ForegroundColor Blue
Write-Host "          Note: This process may take several minutes to complete." -ForegroundColor Cyan
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Dismount-WindowsImage install.wim Started" >> $LogFile
Dismount-WindowsImage -path "c:\mediarefresh\mounted" -save -CheckIntegrity -LogLevel 3 >> $LogDetail
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Dismount-WindowsImage install.wim Completed" >> $LogFile

Write-Host "     Removing \Mounted folder" -ForegroundColor Blue
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     Removing .\mounted folder" >> $LogFile
RD c:\mediarefresh\mounted | out-null
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " |     .\mounted folder removed" >> $LogFile

Write-Host "Updating Install.wim Complete" -ForegroundColor Blue
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " | Install.wim Update Completed" >> $LogFile

Write-Host "Splitting Install.wim" -ForegroundColor Blue
Write-Host "     Note: This process may take several minutes to complete." -ForegroundColor Cyan
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " | Split-WindowsImage Started" >> $LogFile
Split-WindowsImage -ImagePath "c:\mediarefresh\wim\install.wim" -SplitImagePath "c:\mediarefresh\out\sources\install.swm" -FileSize 4000 -CheckIntegrity >> $LogDetail
(get-date).ToString("yyyy-MM-dd HH:mm:ss") + " | Split-WindowsImage Completed" >> $LogFile

Write-Host "Update Complete" -ForegroundColor Blue
Write-Host "Copy contents of c:\mediarefresh\out to your flash drive" -ForegroundColor Blue

その他のリソース