PowerShell script to make a WinPE USB drive

I wanted to take my previous set of scripts to create a WinPE environment  a step further. I wanted a script to create a bootable WinPE USB drive (UFD).

Here is that script (again it is numbered to indicate the order in which to run things). I borrowed the diskpart stuff from here:

Function JBMURPHY-WinPE-7MakeUFD{
$UFD=Get-WmiObject -Class Win32_LogicalDisk | Where-Object {($_.DriveType -eq 2) -and ($_.DeviceID -ne "A:")}
If ($UFD.Count -eq 0){
Write-host "Can't find any UFDs"
"list disk" | diskpart
$DriveToUse=read-host "`nWhat disk do you want to use (just the number)"
If (!($DriveToUse)){exit}

$command= @"
select disk $DriveToUse
create partition primary
select partition 1
format fs=fat32 quick
assign LETTER=K

DiskPart |
Where-Object { $_.Length -gt 0 } |
Foreach-Object { Write-Progress -Activity "Creating New UFD" -Status $_ -Id 1}

copy-item -verbose "$RootDirectory\*" "K:\" -recurse
Comments are closed.

Powered by WordPress. Designed by WooThemes