Hi
Im working on a script that wil collect some info on all of my pc’s in my network.
So far i have this script.


$computers = Get-Content c:\pstest\computerlist.txt
$disks = get-wmiobject -class "Win32_LogicalDisk" -namespace "root\CIMV2" -computername $computer -Filter "DriveType='3'"
$System = Get-WmiObject Win32_ComputerSystem -ComputerName $computer | Select-Object -Property Name

$results = foreach ($computer in $computers)

 
{

        $disk = get-wmiobject -class "Win32_LogicalDisk" -namespace "root\CIMV2" -computername $computer -Filter "DriveType='3'"
        $System = Get-WmiObject Win32_ComputerSystem -ComputerName $computer | Select-Object -Property Name,Model
        $BIOS = Get-WmiObject Win32_BIOS -ComputerName $computer | Select-Object -Property SerialNumber
	    $SystemOS = Get-WmiObject Win32_OperatingSystem -ComputerName $computer | Select-Object -Property caption
        $InstalledRAM = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $computer
        $disk = get-wmiobject -class "Win32_LogicalDisk" -namespace "root\CIMV2" -computername $computer -Filter "DriveType='3'" | Select-Object name,size

   
        [PSCustomObject]@{

            Name = $System.Name
	    	Model = $System.Model
            SerialNumber = $BIOS.SerialNumber
            OperatingSystem = $SystemOS.caption
            Ram = $InstalledRAM = [Math]::Round(($InstalledRAM.TotalPhysicalMemory/ 1GB))
            Drive = $disk.Name
            "Total Disk Size" = $disk
           

        }
    }
$results

$results | Out-GridView
$results | Format-Table -AutoSize
$results | Export-Csv -Path c:\disks.csv -NoTypeInformation -Encoding ASCII

and this is what i get


I want that the answer show only the name and the size (in GB) without the “@{name=C:; size=”.
Additionally i want it to show if the hard disk is ssd or hdd

Thanks for helping me!!

3 Spice ups

If you use get-disk instead of the WMIobject, you will get the disk Size in GB and the AllocatedSize in Bytes.
That way you don’t have to filter your results anymore.

1 Spice up

Thank you . but i am using windows 7 so that " get-disk " is not working…

The i suggest you use split: