Create a Powershell server report using wmi - Noob needs help, please

I’m in need of creating a report that will help retrieve the following items in a CSV format:

Server/ ReportDate / TotalAllocation / UsedGB / SubtractedAmount / BilledAllocation / OperatingSystem / Version

I was able to modify a great script to get a few of the items on my report using the Class Win32_volume but not sure how to get the complete Total disk amount along with the UsedGB for all the Disks on a server.

$Server = Get-WmiObject -Class Win32_volume -computer $computer -filter "drivetype=3 AND DriveLetter != NULL"

I was trying to find a way to utilize the Win32_logicalDisk from the initial script I found but with my limited powershell skills, I was unable to gather/collect the needed information of each server.

$Disks = Get-WmiObject Win32_LogicalDisk -ComputerName $Computer -Filter "DriveType = 3" -ErrorAction Stop

 

Initial script - https://community.spiceworks.com/scripts/show/2147-get-diskinfo

 

Current attempt:

#Working on learning the steps of the script:

#This allows you to control the function of how the cmdlet itself works.  So it will require a Parameter and allows piping.

# Typical input - Get-Content c:\scripts\servers.txt | .\GetServerInfo.ps1 | Sort SystemName | Format-Table

#Most servers being queried will be SErver 2008 R2 or 2012 R2.

[CmdletBinding()]

Param(

[Parameter(Mandatory=$true,

ValueFromPipeline=$true)]

[String[]]$ComputerName,

[switch]$ShowAll

)

#This section creates HASH tables for each iteration it passes the ForEach loop

Begin {

$ServerResults = @()

$DiskResults = @()         

}

#Here is where each server in my servers.txt file will be processed.

Process {

    ForEach ($Computer in $ComputerName)

    {                         

                                $vp = "V"

                                $SAmount = '80'

                                $Drives = $computer.group        

                                $csvdetail = $drives | Select @{ Name = "Server"; Expression = { $computer.name } },

                                @{ Name = "ReportDate"; Expression = { Get-Date -Format g } },

                                @{ Name = "Drive"; Expression = { $_.DriveLetter } },

                                @{ Name = "SizeGB"; Expression = { "{0:N2}" -f ($_.Capacity/1GB) } },

                                @{ Name = "UsedGB"; Expression = { "{0:N2}" -f (($_.Capacity - $_.Freespace)/1GB) } },

                                @{ Name = "FreeGB"; Expression = { "{0:N2}" -f ($_.FreeSpace/1GB) } }

                                $Server = Get-WmiObject -Class Win32_volume -computer $computer -filter "drivetype=3 AND DriveLetter != NULL"

                                $SystemName                                  = $Server.SystemName

                                $ReportDate                      = Get-Date -format g

                                $MachineType                 = $vp

                                $subtractedAmount       = $SAmount

                                <#

                OperatingSystem = $operatingSystem.caption

                Version = $operatingSystem.Caption + " " + $operatingSystem.Version

                TotalAllocation = "{0:N2}" -f (($Drives | Measure-Object Capacity -Sum).Sum/1GB)

                FreeGB = "{0:N2}" -f (($Drives | Measure-Object FreeSpace -Sum).Sum/1GB)

                UsedGB = "{0:N2}" -f ((($Drives | Measure-Object Capacity -Sum).Sum/1GB) - (($Drives | Measure-Object FreeSpace -Sum).Sum/1GB))

                BilledAllocation = "{0:N2}" -f ((($Drives | Measure-Object Capacity -Sum).Sum/1GB) - $subtractedAmount)

                #>

                $ServerInfo = @{

                Server                                                   = $SystemName

                ReportDate                                        = $ReportDate

                MachineType                                    = $MachineType

                SubtractedAmount         = $subtractedAmount

                                                <#

                                                Additional hash variables will be added to above $serverInfo

                                                #>                                          

                                }

                                New-Object PSObject -Property $ServerInfo

                                $ServerInfo

                                }             

    }

End {     

                $ServerInfo

}

I know there are missing parts and I would be very grateful for any help on getting this report complete.

Cheers,