LogoLogo
OSDeploy.comTwitterGitHubPowerShell Gallery
  • OSD PowerShell Module
  • Functions
  • Docs
    • OSDCloud
    • OSDPad
    • OSDHelp
      • Autopilot
    • Guides
      • UEFI System Firmware Update
      • In Your Code
      • New-OSDBoot.usb
      • Partitions
        • New-OSDDisk (Information)
        • New-OSDDiskWinPE (GPT)
        • New-OSDDiskWinPE (2 Disks)
        • AutoUnattend.xml
    • OSDWindowsImage
    • Windows Setup Environment
      • Execution Policy
      • WinSE Settings
      • Import Modules
      • Automation
    • Release Notes
    • Trash
      • Adk
        • Edit-ADKwinpe.wim
        • Get-ADKpaths
        • New-ADK.iso
        • New-ADKcopype
      • Appx
      • Block
      • CloudDriver
      • Dell
        • Get-DellCatalogPC
        • Get-MyDellBIOS
        • Update-MyDellBios
      • Disk
        • Backup-Disk.ffu
        • Clear-LocalDisk
        • Clear-USBDisk
        • Get-LocalDisk
        • Get-OSDDisk
        • Get-USBDisk
        • New-OSDisk
          • Old Version
            • Sandbox
            • Partition Layout
            • Partition Sizes
            • Volume Labels
            • AutoUnattend.xml
        • Get-USBVolume
      • Dism
        • Get-MyWindowsCapability
        • Get-MyWindowsPackage
        • Set-WimExecutionPolicy
        • Set-WindowsImageExecutionPolicy
      • Display
        • Get-VidConRes
      • Driver
        • Get-OSDDriverWmiQ
        • Get-OSDDriver
      • General
        • Get-OSD
        • Get-OSDClass
        • Get-OSDGather
        • Get-OSDPower
        • Get-RegCurrentVersion
        • Get-SessionsXml
        • Save-OSDDownload
      • MyBitLocker
        • Get-MyBitLockerKeyProtectors
        • Backup-MyBitLocker
        • Save-MyBitLockerExternalKey
        • Save-MyBitLockerKeyPackage
        • Save-MyBitLockerRecoveryPassword
        • Unlock-MyBitLockerExternalKey
      • OOBE
      • PSModule
        • Copy-PSModuleToFolder
        • Copy-PSModuleToWim
        • Copy-PSModuleToWindowsImage
      • WebConnection
      • WebPSScript
      • WinPEWim
      • WinPE
        • Enable-PEWimPSGallery
        • Get-OSDWinPE
Powered by GitBook
On this page
  • Getting Started
  • -Force
  • -Force -Confirm:$false
  • -Initialize
  • -PartitionStyle

Was this helpful?

  1. Docs
  2. Trash
  3. Disk

Clear-LocalDisk

OSD 21.2.22+

PreviousBackup-Disk.ffuNextClear-USBDisk

Last updated 4 years ago

Was this helpful?

This function is intended to run from WinPE and is ideally used to clear all Local Disks returned by Get-LocalDisk. I use this to clear all Local Disks (OS and DATA) before an OS Deployment

Getting Started

I strongly recommend running it without any parameters. By default, the following information is presented

Clear-LocalDisk
  1. -Verbose is enabled

  2. Detected UEFI and PartitionStyle are displayed

  3. Get-Help Clear-LocalDisk

  4. Get-LocalDisk | Format-Table is displayed

-Force

When the -Force parameter is used, things are a little different

Clear-LocalDisk -Force
  1. Get-LocalDisk | Format-Table is displayed

  2. Confirm for each LocalDisk

  3. Get-LocalDisk | Format-Table is updated and displayed

    1. PartitionStyle = RAW

    2. NumberofPartitions = 0

-Force -Confirm:$false

This leaves no room for error as there are no confirmation prompts

Clear-LocalDisk -Force -Confirm:$false

-Initialize

Adding this parameter will initialize the Disk in either GPT or MBR. If the system is UEFI, then GPT is automatically enabled

-PartitionStyle

Using this parameter you can override the automatic selection of the PartitionStyle. In this example, a UEFI with GPT would have been automatically selected, but specifying -PartitionStyle MBR overrode that