Automation

 View Only
  • 1.  Trying to export IP address to CSV, no information

    Posted Jun 10, 2015 01:48 PM

    Hey LucD!

    I'm continuing with my validation script.  I want to  export the information by the following headings:

    Name NumCpu MemoryMB CapacityGB NetworkName IPAddress Description

    I'm getting results for everything except for IP address, can you spot where I went wrong?

    Get-VM CUST* | select Name, NumCpu, MemoryMB,@{N='CapacityGB';E={Get-HardDisk -VM $_ | select -ExpandProperty CapacityGB}},@{N='NetworkName';E={Get-NetworkAdapter -VM $_ | select -ExpandProperty NetworkName}},@{N='IPAddress';E={$_.guest.IPAddress[0] | select -ExpandProperty IPAddress}}, Description | Export-Csv -path "c:\output.csv" -NoTypeInformation

    Thanks.



  • 2.  RE: Trying to export IP address to CSV, no information
    Best Answer

    Posted Jun 10, 2015 02:23 PM

    You don't need to do the Select -Expandproperty, just do

    Get-VM CUST* |

    select Name, NumCpu, MemoryMB,

        @{N='CapacityGB';E={Get-HardDisk -VM $_ | select -ExpandProperty CapacityGB}},

        @{N='NetworkName';E={Get-NetworkAdapter -VM $_ | select -ExpandProperty NetworkName}},

        @{N='IPAddress';E={$_.guest.IPAddress[0]}},

        Description