This example creates a new partition using the entire space available on drive number 2: New-Partition -DiskNumber 2 -UseMaximumSize In the command, change DISK-NUMBER to the correct number representing the storage you are formatting.
This example selects and cleans the disk number 2: Get-Disk 2 | Clear-Disk -RemoveData In the command, change DISK-NUMBER for the correct number representing the flash drive you are formatting. Type the following command to delete the volume and press Enter: Get-Disk DISK-NUMBER | Clear-Disk -RemoveData.Type the following command to view the flash drive you want to fix and press Enter: Get-Disk.To clean and format a removable drive with PowerShell commands, use these steps: Clean and format flash drive using PowerShell
This example performs a full format of the "F" drive: Format-Volume -DriveLetter F -FileSystem NTFS -Full -ForceĪfter you complete the steps, PowerShell will format the removable storage with the settings you specified. The Full option tells the command to perform a full format, and the -Force option specifies the override switch.
If you do not know and are on Windows 10, you should use NTFS. In the command, replace DRIVE-LETTER with the correct letter reflecting the drive you want to format, and FILE-SYSTEM for FAT32, exFAT, or NTFS, depending on the file system you want to use.
How to format USB flash drive with PowerShell Once you complete the steps, the process will create a new partition and set up the file system, fixing common problems with the flash drive, including data corruption. (Optional) Check the Enable file and folder compression option.
As a result, this process can take a long time, depending on the size of the drive. If you do not check the option, a full format operation will be performed, and it will do a scan for bad sectors and write zeros in all sectors deleting the data. Quick note: The "Quick format" option only deletes the file system table and the root folder, but the data may still be recoverable.Under the "Format options" section, select the Quick format option.In the "Volume label" field, confirm a drive name that will appear in File Explorer.Use the default selection in the "Allocation unit size" drop-down menu.However, if you think you might use the device on a Linux machine, "FAT32" is the best option, even though you will be limited to 4GB file sizes.