Forum Discussion

SharveshS's avatar
SharveshS
Copper Contributor
Mar 16, 2021

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

 

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.

 

Resources