PowerShell을 사용하여 DaRT 10 관리

Microsoft DaRT(Diagnostics and Recovery Toolset) 10을 사용하면 PowerShell 명령을 사용하여 다양한 DaRT 10 관리 작업을 완료하거나 DaRT 복구 이미지를 만들 수 있습니다.

PowerShell을 사용하여 DaRT 작업 수행

DaRT(Microsoft Diagnostics and Recovery Toolset) 10은 다음과 같은 나열된 Windows PowerShell cmdlet 집합을 제공합니다. 관리자는 이러한 PowerShell cmdlet을 사용하여 DaRT 복구 이미지 마법사가 아닌 명령 프롬프트에서 다양한 DaRT 10 서버 작업을 수행할 수 있습니다.

이름 설명
Copy-DartImage CD, DVD 또는 USB 드라이브에 ISO를 굽습니다.
Export-DartImage DaRT 이미지가 포함된 원본 WIM 파일을 ISO 파일로 변환할 수 있습니다.
New-DartConfiguration Windows 이미지에 DaRT 도구 집합을 적용하는 데 필요한 DaRT 구성 개체를 만듭니다.
Set-DartImage 탑재된 Windows 이미지에 DartConfiguration 개체를 적용합니다.

PowerShell 스크립트를 사용하여 복구 이미지 만들기

DaRT 10 복구 이미지 마법사를 사용하는 대신 PowerShell 스크립트를 사용하여 DaRT 10 복구 이미지를 만들 수 있습니다. 또한 DaRT 10 복구 이미지 마법사는 지정된 설정에 따라 PowerShell 스크립트를 사용할 수 있습니다.

다음은 DaRT 10 복구 이미지 마법사가 만든 PowerShell 스크립트의 예입니다.

###
### DaRT Image Creation Script
###
### This script was auto generated by the Microsoft DaRT Recovery Image Wizard.
###
### This script uses the DISM and DaRT PowerShell commands to create a bootable DaRT image.
### Both a WIM and ISO file are produced.
###
### Examples of how to burn/copy the DaRT ISO to DVD/USB are available at the end of this script.
###

### This variable tells PowerShell to stop if an error occurs.
$ErrorActionPreference = "Stop";

###
### Import the modules necessary for DaRT Image creation.
###

Import-Module "Dism"
Import-Module "Microsoft.Dart"

###
### Specifies where the Windows media is located and where the ISO and WIM files will be saved.
### These can be changed as necessary.
###

$WinMediaPath = "D:\";                                                          ### This is the path of the Windows media.
$DestinationWimPath = "C:\Users\Administrator\Desktop\DaRT10\x64\boot.wim";     ### Specify where the WIM file will be saved.
$DestinationIsoPath = "C:\Users\Administrator\Desktop\DaRT10\x64\DaRT10.iso";   ### Specify where the ISO will be saved.

###
### These variables are used to specify temporary and output directories based on the paths above.
###

$WimParentPath = (Split-Path -Path "$destinationWimPath" -Parent);              ### Specify the directory where the DaRT WIM file will be saved.
$IsoParentPath = (Split-Path -Path "$destinationIsoPath" -Parent);              ### This is the directory where the DaRT ISO file will be saved.
$TempMountPath = "$([System.IO.Path]::GetTempPath())\DaRT8Mount_$(Get-Random)"; ### Specify the temporary directory used to mount the Windows image.

###
### Prepare the Windows image.
###

### Verify that the output directories exist.
New-Item -Path $WimParentPath -Type Directory -Force
New-Item -Path $IsoParentPath -Type Directory -Force
New-Item -Path $TempMountPath -Type Directory -Force

### Create a copy of the WIM and remove the read-only attribute.
### The WIM file will be the resulting DaRT image.
Copy-Item "$WinMediaPath\sources\boot.wim" $DestinationWimPath -Force
Set-ItemProperty $DestinationWimPath -Name IsReadOnly -Value $false

### Mount the bootable image within the WIM file (normally index 2).
Mount-WindowsImage -ImagePath $DestinationWimPath -Path $TempMountPath -Index 2

###
### Add additional drivers to the image.
###

### The following is an example of how to add additional drivers to the image. 
### Specify the actual path to a driver's INF file and uncomment the following statement.
# Add-WindowsDriver -Path $TempMountPath -Driver "c:\example\path\to\drivers.inf" -ForceUnsigned

###
### Installs the specified WinPE package(s) into the image.
###

Add-WindowsPackage -Path $TempMountPath -PackagePath "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-EnhancedStorage.cab"

Add-WindowsPackage -Path $TempMountPath -PackagePath "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-WMI.cab"

Add-WindowsPackage -Path $TempMountPath -PackagePath "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-WinReCfg.cab"

Add-WindowsPackage -Path $TempMountPath -PackagePath "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-FMAPI.cab"

Add-WindowsPackage -Path $TempMountPath -PackagePath "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-FontSupport-WinRE.cab"

Add-WindowsPackage -Path $TempMountPath -PackagePath "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-Scripting.cab"

Add-WindowsPackage -Path $TempMountPath -PackagePath "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-EnhancedStorage_en-us.cab"

Add-WindowsPackage -Path $TempMountPath -PackagePath "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-Scripting_en-us.cab"

Add-WindowsPackage -Path $TempMountPath -PackagePath "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-WMI_en-us.cab"

Add-WindowsPackage -Path $TempMountPath -PackagePath "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-WinReCfg_en-us.cab"

Add-WindowsPackage -Path $TempMountPath -PackagePath "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-NetFx.cab"

Add-WindowsPackage -Path $TempMountPath -PackagePath "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-NetFx_en-us.cab"

Add-WindowsPackage -Path $TempMountPath -PackagePath "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-PowerShell.cab"

Add-WindowsPackage -Path $TempMountPath -PackagePath "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-PowerShell_en-us.cab"

Add-WindowsPackage -Path $TempMountPath -PackagePath "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-DismCmdlets.cab"

Add-WindowsPackage -Path $TempMountPath -PackagePath "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-DismCmdlets_en-us.cab"

###
### Add the DaRT tools to the image.
### The New-DartConfiguration cmdlet is used to specify how the DaRT image is configured.
### Modify this statement to configure how the DaRT tools will be applied to the image.
###

$config = New-DartConfiguration -AddComputerManagement -AddCrashAnalyzer -AddDiskCommander -AddDiskWipe -AddExplorer -AddFileRestore -AddFileSearch -AddHotfixUninstall -AddLocksmith -AddRegistryEditor -AddSfcScan -AddSolutionWizard -AddTcpConfig
$config | Set-DartImage -Path $TempMountPath

###
### Perform any manual user-specific customizations here.
###

# Read-Host -Prompt "Script is paused for any manual customization. Press ENTER to continue"

### Save the changes to the WIM file by dismounting the image.
Dismount-WindowsImage -Path $TempMountPath -Save

### Create a bootable DaRT ISO.
Export-DartImage -IsoPath $DestinationIsoPath -WimPath $DestinationWimPath

### The following is an example of how to burn the ISO to a writeable CD/DVD.
### Specify the correct drive letter and uncomment the statement to burn an ISO.
# Copy-DartImage -IsoPath $DestinationIsoPath -Drive "G:" -Type DVD

### The following is an example of how to format and copy the ISO to a USB drive.
### Specify the correct drive letter and uncomment the statement to create a bootable USB.
# Copy-DartImage -IsoPath $DestinationIsoPath -Drive "G:" -Type USB

### Removes all temporary files.
Remove-Item $TempMountPath -Force -Recurse