Hi, I’m trying to create a oneliner gathering Diskinformation. Although I basically succeed in what I am trying to do, i.e. I get the information I want formatted in the way I want, but it’s also throwing me errors. Here’s the code:
$DiskInfo = @( gwmi cim_LogicalDisk | where {$_.DriveType -eq '3'} -PipelineVariable Ldisk | % {gwmi cim_LogicalDiskBasedOnPartition | Where {$_.Dependent -eq $Ldisk.__Path}-PipelineVariable L2P | gwmi Cim_DiskPartition | where {$_.__Path -eq $L2P.Antecedent} -PipelineVariable Part | gwmi cim_DiskDrive | where {$_.Index -eq $Part.DiskIndex} -PipelineVariable Disk | select @{n = "Disk"; e = {$_.index -as [int]} }, @{n = "Model"; e = {$_.Model -as [string]} }, @{n = "Firmware"; e = {$_.FirmwareRevision -as [string]} }, @{n = "SerialNumber"; e = {$_.SerialNumber -as [string]} }, @{n = "DiskSize(GB)"; e = {"{0:N1}" -f( $Disk.Size / 1024MB)} }, @{n = "Partitions"; e = {$_.Partitions -as [int] } }, @{n = "Partition"; e = {$Part.index -as [int]} }, @{n = "BootPartition"; e = {$Part.BootPartition -as [string]} }, @{n = "PartionSize(GB)"; e = {"{0:N1}" -f ($Part.size /1024MB)} }, @{n = "Blocks"; e = {$Part.NumberOfBlocks -as [int]} }, @{n = "BlockSize"; e = {$Part.BlockSize -as [int]} }, @{n = "LDiskName"; e = {$Ldisk.Caption -as [string]} }, @{n = "FileSystem"; e = {$Ldisk.Filesystem -as [string]} }, @{n = "LDiskSize"; e = {"{0:N1}" -f ($Ldisk.size /1024MB)}}, @{n = "LDiskFree"; e = {"{0:N1}" -f ($Ldisk.FreeSpace /1024MB)}} } )
What am I doing wrong?
Any help would be great.