- 1 year ago
Fetching volume number in PowerShell
In PowerShell, you can use the Get-Volume
cmdlet to fetch volume information, including the volume number, on a Windows system. The volume number is a unique identifier assigned to each volume on the system.
Here's how you can fetch the volume number using PowerShell:
powershell# Fetch all volume information
$volumes = Get-Volume
# Display volume information including the volume number
$volumes | Select-Object DriveLetter, FileSystemLabel, FileSystem, Size, SizeRemaining, VolumeNumber
In the above code, we use the Get-Volume
cmdlet to retrieve all volume information, including the volume number. The output of Get-Volume
contains several properties related to each volume, such as DriveLetter
, FileSystemLabel
, FileSystem
, Size
, SizeRemaining
, and VolumeNumber
.
The Select-Object
cmdlet is then used to choose specific properties to display. In this case, we are displaying the DriveLetter
, FileSystemLabel
, FileSystem
, Size
, SizeRemaining
, and VolumeNumber
properties for each volume.
The VolumeNumber
property contains the volume number, which uniquely identifies each volume on the system. The volume number is an internal identifier used by Windows and can be useful when dealing with volume-specific operations.
You can run the above code in a PowerShell console or script to fetch and display the volume information along with the corresponding volume numbers on your Windows system.