/
DeployWindowsPE.ps1
30 lines (23 loc) · 1020 Bytes
/
DeployWindowsPE.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
$Wimfile='C:\Pewim\custom.wim'
$OSDrive='L'
$WinPEDrive='C'
$Disk
$DriverPath='C:\Dell'
$WinPETemp='C:\TempPE'
$Disk=Get-AttachedDisk -USB -GUI
$Env:WinPERoot="$($WinPEDrive)`:\Program Files$(Get-ArchitectureString)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment"
$WinADK="$($Env:WinPERoot)\amd64"
Remove-item -Path $WinPETemp -Recurse -Force
New-Item -ItemType Directory -Path $WinPETemp -Force
Copy-Item -Path "$WinAdk\Media" -Destination $WinPETemp -Recurse -Force
New-Item -ItemType Directory -Path "$WinPETemp\Media\Sources" -Force
Copy-Item -path "$WinAdk\en-us\winpe.wim" -Destination "$WinPETemp\Media\Sources\boot.wim"
if ($Wimfile -ne $NULL)
{
Copy-Item -Path $Wimfile -Destination "$WinPETemp\Media\Sources\boot.wim"
}
New-PartitionStructure -Disk $disk -OSDrive $OSDrive -USB -MBR
$WinPEKey=$OsDrive+':'
Copy-Item -Path "$WinPETemp\Media\*" -destination "$WinPeKey\" -Recurse
Send-BootCode -OSDrive $OSDrive -USB
Remove-DriveLetter -DriveLetter $OSDrive