PowerCLI

 View Only
  • 1.  export data to cvs file

    Posted Nov 05, 2023 03:30 PM

    Hello,

    I need help to write script to get some information of all VMs in cluster1  

    information needed to be exported to cvs file are: 

    VM name, the guest OS, how many vNIC in this VM,  and for each network a VNIC i need the IP address, the DNS, the gatway the netmask and the portgroup

    Thank you in advance

    Ahmed



  • 2.  RE: export data to cvs file

    Posted Nov 05, 2023 03:48 PM

    Did you do a search in this community?
    All your requirements have been handled in other posts in here.



  • 3.  RE: export data to cvs file
    Best Answer

    Posted Nov 05, 2023 04:30 PM

    thank you very much lucd for your prompt reply .

    I have found some information in this community like how to export the VMname, the guestOS, in the CSV file. that's clear for me.

    Get-Cluster -Name cluster1 | Get-VM | Get-NetworkAdapter | `
    Select-Object -Property `
    @{N="VM Name";E={$_.Parent}},
    @{N="NIC Name";E={$_.Name}},
    @{N="Network Name";E={$_.NetworkName}} |
    Export-Csv -Path c:\NetworkAdapters.csv -NoTypeInformation -UseCulture

    but I didn't see how to integrate the result of invoke-script in the same CSV file

    Invoke-VMScript -VM VMName -scripttext "Get-NetIPConfiguration" -GuestUser user -GuestPassword password

    I need to concatenate the two output in the same file so the the result should be in this format

    VMname    VNICname     NetworkName     IPAddress     DNS    Gateway     netMask



  • 4.  RE: export data to cvs file
    Best Answer