PowerShell has a builtin option to save to a CSV file.
Like this
Get-VM|
Select Name,NumCPu,MemoryGB,UsedSpaceGB,
@{N='GuestOS';E={$_.Guest.OSFullName}}|
Export-Csv-Path .\report.csv -NoTypeInformation -UseCulture
If you want to save the result to a .xlsx file, you will need to install the ImportExcel module.
you can do that with the Install-Module cmdlet.
Install-Module-Name ImportExcel
Then the earlier script becomes
Get-VM|
Select Name, NumCPu, MemoryGB, UsedSpaceGB,
@{N='GuestOS';E={$_.Guest.OSFullName}}|
Export-Excel-Path .\report.xlsx