The standard way of getting the drive listing of a computer with PowerShell is by means of the class Win32_LogicalDisk of the Get-WmiObject commandlet.
But a problem happens if you have a NFS mapped drive in your computer. If this is the case the result of the call is an exception:
PS C:\Windows\SysWOW64> Get-WMIObject win32_LogicalDisk
Get-WmiObject : Apagando
En línea: 1 Carácter: 14
+ Get-WMIObject <<<< win32_LogicalDisk
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
If this is you case you can delete the mapping to the NFS drive to stop getting the error. But if you can't, or wan't, or do not know if the computer where you will run the script over has this kind of mappings, you may use the following alternate form to get the needed data:
get-wmiobject -class "Win32_MappedLogicalDisk" -namespace "root\CIMV2"
This class return a information similar to that gou get by using the former class but it work even if you have NFS drives mapped in the computer you make the call on.