# Clear-LocalDisk

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

![](/files/-MUCHEkNWvwj_TDU2wm2)

## -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

![](/files/-MUCHXrHDmFpdv6qz7jZ)

## -Force -Confirm:$false

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

```
Clear-LocalDisk -Force -Confirm:$false
```

![](/files/-MUCI_RlrMSO1YdTZRnk)

## -Initialize

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

![](/files/-MUCNAN3IWdbJ9QhGXj1)

## -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

![](/files/-MUCNG7u6nLW0GzPi1Ut)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://osd.osdeploy.com/docs/trash/disk/clear-localdisk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
