Param($DriveLetter) if ($PSBoundParameters.Count -ne 1) { exit } $DriveLetter = $DriveLetter.Substring(0,1) try { $used = (Get-PSDrive -Name $DriveLetter -ErrorAction Stop).Used $free = (Get-PSDrive -Name $DriveLetter -ErrorAction Stop).Free $total= $used + $free return ($free / $total * 100) } catch { exit }