Desktop/Private/PathUtilities/Get-VolumeName.ps1
|
# src/Private/PathUtilities/Get-VolumeName.ps1 <# .SYNOPSIS Returns the filesystem label for a drive. .DESCRIPTION The Get-VolumeName cmdlet retrieves the filesystem label (volume name) for the drive associated with the specified path. Used only in Tree.com compatibility mode. .PARAMETER Path The path used to identify the drive/volume. Defaults to the current directory. #> function Get-VolumeName { [CmdletBinding()] param( [string]$Path = "." ) if (-not $PSBoundParameters.ContainsKey('Debug') -and $PSCmdlet) { $DebugPreference = $PSCmdlet.GetVariableValue('DebugPreference') } if (-not $PSBoundParameters.ContainsKey('Verbose') -and $PSCmdlet) { $VerbosePreference = $PSCmdlet.GetVariableValue('VerbosePreference') } $driveLetter = (Get-Item $Path).PSDrive.Name $volume = Get-Volume -DriveLetter $driveLetter $volume.FileSystemLabel } |