Windows · December 16, 2023

PowerShell Command: Add-PhysicalDisk

PowerShell Command: Add-PhysicalDisk

When it comes to managing storage on a VPS or any other server, PowerShell is an incredibly powerful tool. One of the most useful commands for managing storage is the Add-PhysicalDisk command. This command allows you to add a physical disk to a storage pool, which can be very useful for expanding your storage capacity or for setting up a new storage pool.

What is Add-PhysicalDisk?

The Add-PhysicalDisk command is a part of the Storage module in PowerShell. It is used to add a physical disk to a specified storage pool. This command is particularly useful when you need to expand the storage capacity of your hosting environment or when you are setting up a new storage pool.

How to Use Add-PhysicalDisk

To use the Add-PhysicalDisk command, you first need to identify the disk that you want to add to the storage pool. You can do this by using the Get-PhysicalDisk command to list all the physical disks that are available on your system. Once you have identified the disk, you can use the Add-PhysicalDisk command to add it to the storage pool.

Get-PhysicalDisk | Where-Object { $_.CanPool -eq $True }
Add-PhysicalDisk -StoragePoolFriendlyName "MyStoragePool" -PhysicalDisks $Disk

In the example above, we first use the Get-PhysicalDisk command to list all the physical disks that can be pooled. We then use the Add-PhysicalDisk command to add the disk to the storage pool named "MyStoragePool".

Examples of Add-PhysicalDisk

Here are some examples of how you can use the Add-PhysicalDisk command in different scenarios:

  • Adding a new disk to an existing storage pool:
$Disk = Get-PhysicalDisk -FriendlyName "NewDisk"
Add-PhysicalDisk -StoragePoolFriendlyName "ExistingPool" -PhysicalDisks $Disk
  • Adding multiple disks to a storage pool:
$Disks = Get-PhysicalDisk | Where-Object { $_.CanPool -eq $True }
Add-PhysicalDisk -StoragePoolFriendlyName "MyStoragePool" -PhysicalDisks $Disks
  • Adding a disk to a storage pool and specifying the usage type:
$Disk = Get-PhysicalDisk -FriendlyName "NewDisk"
Add-PhysicalDisk -StoragePoolFriendlyName "MyStoragePool" -PhysicalDisks $Disk -Usage AutoSelect
Benefits of Using Add-PhysicalDisk

There are several benefits to using the Add-PhysicalDisk command in PowerShell:

  • It allows you to easily expand the storage capacity of your VPS or server.
  • It is a quick and efficient way to add new disks to a storage pool.
  • It gives you the ability to specify the usage type of the disk, such as AutoSelect, HotSpare, or Journal.
  • It is a part of the Storage module in PowerShell, which means it is designed to work seamlessly with other storage-related commands.
Conclusion

In conclusion, the Add-PhysicalDisk command is a powerful and useful tool for managing storage on a VPS or server. It allows you to easily add new disks to a storage pool, expand your storage capacity, and specify the usage type of the disk. By incorporating relevant examples and code samples, we have shown how this command can be used in different scenarios. Whether you are setting up a new storage pool or expanding an existing one, the Add-PhysicalDisk command is a valuable tool to have in your arsenal.