How to get CSV output for Get-VM and Get-VMNetworkAdapter properties using single PowerShell script?

Copper Contributor

 

PS C:\User> Get-VM -Name * | Select-Object -Property Name,State,CPUUsage | Export-Csv -Path E:\MYfolder/report.csv -NoTypeInformation              #giving csv expected results alone
PS C:\User> Get-VMNetworkAdapter -Name * | Select-Object -Property MacAddress,IPAddresses | Export-Csv -Path E:\MYfolder/report.csv -NoTypeInformation         #giving csv expected results alone

 

 

I am newly started my coding and stuck with building a PowerShell above script. How to write a single script to execute Get-VM and Get-VMNetworkAdapter with designated properties. Trying to Get VM information's from Hyper-V host or windows server. Output: should be a single csv file.

 

1 Reply