Skip to content

Instantly share code, notes, and snippets.

@brianfgonzalez
Created May 7, 2019 21:04
Show Gist options
  • Save brianfgonzalez/03d9528a84836a55e450c40b67f13bf8 to your computer and use it in GitHub Desktop.
Save brianfgonzalez/03d9528a84836a55e450c40b67f13bf8 to your computer and use it in GitHub Desktop.
This script is meant to run in Windows PE and requires the following PE packages: StorageWmi, Powershell, and .NET
if ((Get-Disk).NumberOfPartitions -eq 4)
{
[System.IO.DriveInfo]::GetDrives() | `
? { (($_.DriveType -eq 'Fixed') -and ($_.VolumeLabel -eq 'RECOVERY')) } | `
% {
Write-Host ('{0}util' -f $_.RootDirectory)
if (test-path ('{0}MININT' -f $_.RootDirectory)) { Remove-Item ('{0}MININT' -f $_.RootDirectory) -Force -Recurse }
if (test-path ('{0}_SMSTaskSequence' -f $_.RootDirectory)) { Remove-Item ('{0}_SMSTaskSequence' -f $_.RootDirectory) -Force -Recurse }
if (test-path ('{0}util' -f $_.RootDirectory)) { Remove-Item ('{0}util' -f $_.RootDirectory) -Force -Recurse }
}
} else {
Initialize-Disk 0
Clear-Disk 0 -RemoveData -Confirm:$false | out-null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment