How to combine output from Get-CimInstance and Get-WMIObject functions

Viewed 1463

I have got 2 powershell scripts, which I have mentioned below. I am looking for a way to combine both of these scripts. However I am unable to do so as one of the script is using CIM method and the other one is using the WMI method.

What I am trying to accomplish, is to provide the last reboot time and free space available of the same server (User has to enter the server name and on pressing Enter it shows the last reboot time and free space available).

Script 1 (CIM Method) :

$Server = Read-Host -Prompt 'Input your server  name'
Get-CimInstance -ClassName win32_operatingsystem -ComputerName $Server | select csname, lastbootuptime
Read-Host -Prompt "Press Enter to exit"

Script 2 (WMI Method) :

$Server = Read-Host -Prompt 'Input your server  name'
Get-WMIObject Win32_Logicaldisk -ComputerName $Server | Select PSComputername,DeviceID, @{Name="Total_Size_GB";Expression={$_.Size/1GB -as [int]}}, @{Name="Free_Space_GB";Expression={[math]::Round($_.Freespace/1GB,2)}}
Read-Host -Prompt "Press Enter to exit"
1 Answers
Related