# 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

![](https://3420392058-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpnxLqvh8u2fEz86kIM%2F-MUBsHI57FuuQno3Nncn%2F-MUCHEkNWvwj_TDU2wm2%2Fimage.png?alt=media\&token=09313cdc-f84d-490e-9efe-fdb6d7aa23df)

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

![](https://3420392058-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpnxLqvh8u2fEz86kIM%2F-MUBsHI57FuuQno3Nncn%2F-MUCHXrHDmFpdv6qz7jZ%2Fimage.png?alt=media\&token=9a93650d-c0e7-4710-a32f-7a1d1c9175f8)

## -Force -Confirm:$false

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

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

![](https://3420392058-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpnxLqvh8u2fEz86kIM%2F-MUBsHI57FuuQno3Nncn%2F-MUCI_RlrMSO1YdTZRnk%2Fimage.png?alt=media\&token=327c50e2-21ec-41ba-b06d-e9d4e28af0f9)

## -Initialize

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

![](https://3420392058-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpnxLqvh8u2fEz86kIM%2F-MUBsHI57FuuQno3Nncn%2F-MUCNAN3IWdbJ9QhGXj1%2Fimage.png?alt=media\&token=1b092f3e-e4b7-41bb-a3e2-f8e79c6ca76a)

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

![](https://3420392058-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpnxLqvh8u2fEz86kIM%2F-MUBsHI57FuuQno3Nncn%2F-MUCNG7u6nLW0GzPi1Ut%2Fimage.png?alt=media\&token=4e3e3775-fbf9-41f6-83e0-bbb32175c142)
