script to get report on for CPU usage, Memory usage and Free disk space

good morning,
I found this script on one of posting here and it was very helpful. I would like with the helps to modifying adding few output. I not getting it correctly.

I would like to add:
1) which executable program is using high CPU usage ( and duration time )
2)  how long user login duration ?
3)  can I change the freespace title to "freespace of C drive"
4) attach and email the report
5) bonus but not require last reboot time
6) bonus but not require, html format and email


---------------------------------------------------------------------------

GC C:\Temp\list.txt | % {
$Comp = $_
If (Test-Connection $Comp -Quiet){
$Luser = (Get-WmiObject -class win32_process -Filter "Name='Explorer.exe'" -ComputerName $Comp | % {$_.GetOwner().User} | Sort-Object -Unique) -join ","
$Mem = GWMI -Class win32_operatingsystem -computername $COMP
      New-Object PSObject -Property @{
      Server = $Comp
      "CPU usage" = "$((GWMI -ComputerName $COMP win32_processor | Measure-Object -property LoadPercentage -Average).Average) %"
      "Memory usage" = "$("{0:N2}" -f ((($Mem.TotalVisibleMemorySize - $Mem.FreePhysicalMemory)*100)/ $Mem.TotalVisibleMemorySize)) %"
        "Total FreeSpace" = "$("{0:N2}" -f ((Get-WmiObject -Class win32_Volume -ComputerName $COMP -Filter "DriveLetter='C:'" | Measure-Object -property FreeSpace -Sum).Sum /1GB)) GB"
       "logged Users" = $Luser
       }
  }
  Else{
  "" | Select @{N="Server";E={$Comp}},"CPU usage","Memory usage","Total FreeSpace","logged Users"
  }
 }| Select Server,"CPU usage","Memory usage","Total FreeSpace","logged Users" |
 Export-Csv "C:\Temp\report$(Get-Date -F dd_MM_yyy_hhmm).csv" -nti
-------------------------------------------------------------------------------------------
Jimmy WangAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
All Courses

From novice to tech pro — start learning today.