Remove PhysicalDisk - PowerShell
Overview
The Remove-PhysicalDisk
command removes the specified physical disk from the system, making it inaccessible to the operating system. It is primarily used when a physical disk is no longer required or needs to be replaced.
Syntax
Remove-PhysicalDisk [-SerialNumber] <String> [-Force] [-Confirm] [-WhatIf] [-PassThru]
Options/Flags
- -SerialNumber: (Required) Specifies the serial number of the physical disk to be removed.
- -Force: Suppresses the confirmation prompt and forcibly removes the disk.
- -Confirm: Prompts for confirmation before removing the disk.
- -WhatIf: Simulates the command execution without making any changes to the system.
- -PassThru: Returns an object representing the removed disk.
Examples
Simple Removal:
Remove a physical disk with the serial number “123456”
Remove-PhysicalDisk -SerialNumber 123456
Forced Removal:
Forcefully remove a physical disk without confirmation, even if it is currently in use:
Remove-PhysicalDisk -SerialNumber 123456 -Force
Common Issues
- Disk is in use: If the disk is currently being used by the system or a program, the removal will fail. Close any programs or services that may be accessing the disk and try again.
- Incorrect Serial Number: Ensure that the specified serial number matches the physical disk you intend to remove.
Integration
- Get-PhysicalDisk: Use this command to retrieve a list of physical disks in the system and identify the one to be removed.
- Format-Disk: After removing a physical disk, you can format and prepare it for use with
Format-Disk
.