I want to list the files of C: drive. First of all, I want to get the device ID from logical disk wmi object, and list it.
Below command returns:
Get-WmiObject -class Win32_logicaldisk
DeviceID : C:
DriveType : 3
ProviderName :
FreeSpace : 940371968
Size : 125809192960
VolumeName :
But this command:
Get-WmiObject -class Win32_logicaldisk | select deviceid | Get-ChildItem -path {$_}
gives below error:
Get-ChildItem : Cannot find drive. A drive with the name '@{deviceid=C' does not exist. At line:1 char:60
+ Get-WmiObject -class Win32_logicaldisk | select deviceid | Get-ChildItem -path { ...
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (@{deviceid=C:String) [Get-ChildItem], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem -path accepts pipeline input, how we can solve this ?