Skip to Main Content
Status Under review
Product Area OSD Community Tools
Categories OSDCloud
Created by Patrick Davis
Created on May 14, 2026

Have OSDCloud wipe OEM Partitions automatically

OSDCloud does not handle OEM partitions during the disk wipe phase

we solved this using the following function - HP is called out in the popup prompt that we are exposing to our Desktop Techs as we are primarily a HP shop, but this handles all OEM and their partition settings.

        #Starting the Custom Gui

$parts = (Get-Partition | Select-Object type,isboot,nodefaultdriveletter)
$showPrompt = $false
foreach ($part in $parts) {
if ($part.type -ieq 'basic' -and !$part.isboot -and $part.nodefaultdriveletter) {
$showPrompt = $true
}
}

if ($showPrompt) {
Add-Type -AssemblyName PresentationCore, PresentationFramework
$response = [system.windows.messagebox]::show('An HP OEM partition has been detected on this device. This can sometimes prevent OSDCloud from properly cleaning the drive before reinstalling Windows. Press Yes below to pre-wipe the drive to circumvent this issue.

Do you want to pre-wipe the internal hard drive?', 'OEM Partition detected!', 'yesno')
if ($response -eq 'Yes') {
Write-Host 'Wiping the internal drive'
Set-DriveCleanup
Write-Host 'Internal Drive Successfully'
} else {
Write-Host 'Not wiping drive'
}
}
  • Attach files
  • Patrick Davis
    May 14, 2026

    here is the Set-DriveCleanup function for review:

    function Set-DriveCleanup {
    
    <#
    .SYNOPSIS
    Function to clean the internal drive of a machine during OSDCloud before the OSDCloudGui loads

    .EXAMPLE
    Set-DriveCleanup

    .INPUTS
    None
    You cannot pipe objects to Set-DriveCleanup.

    .OUTPUTS
    None
    The cmdlet does not return any output.
    #>

    [CmdletBinding()]
    param()
    #Get all non-removable drives and their size - accounts for USB media not being pulled from device.
    $Drives = Get-CimInstance -Class Win32_DiskDrive | Where-Object { $_.MediaType -ne 'Removable Media' } | Sort-Object Size -Descending

    #Accounts for USB Media being pulled out or broken internal device drive.
    if ($Drives.Count -eq 0) {
    Write-Host 'No Internal drives found in this device.'
    return
    }

    #The largest non-removable drive is the first one in the sorted list
    $LargestDrive = $Drives[0]
    Write-Host "Largest non-removable drive detected: $($LargestDrive.DeviceID) with size $($LargestDrive.Size / 1GB) GB."

    #Clean the drive
    Clear-Disk -Number $Drives[0].Index -RemoveData -RemoveOEM -PassThru -Confirm:$false -Verbose
    #Initialize the drive
    Initialize-Disk -Number $Drives[0].Index -Confirm:$false -PartitionStyle GPT -Verbose
    #Partition the drive
    New-Partition -DiskNumber $Drives[0].Index -UseMaximumSize -AssignDriveLetter | Format-Volume -FileSystem NTFS -Confirm:$false -Verbose
    #Closing Message
    Write-Host "Drive $($LargestDrive.DeviceID) has been wiped. Now presenting the Imaging GUI"
    }