VMware Cloud Community
jmvirtual
Enthusiast
Enthusiast
Jump to solution

Get-VMGuestNetworkInterface - Export

Hey Guys,

I am having an issue exporting the DNS settings of my VM's using the Get-VMGuestNetworkInterface. Everytime I export it i just get SYSTEM.STRING()... I have set the results to a variable and then tried to loop through the array and concatenate it in to one string... but its almost like it losses scope... The end result is that I need to export the dns settings of each vm to a spreadsheet.

$DNSArray = Get-VMGuestNetworkInterface -VM $VM.Name | Select VM, Dns

  Write-Host $DNSArray.Dns

  forEach($IP in $DNSArray.Dns)

  {$DNS = $DNS + " " + $IP}

  if ( $DNS.Length -eq 0 )

  {

  $DNS = "Failed To Obtain"

  }

  write-host $DNS

Any help much appreciated.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
jmvirtual
Enthusiast
Enthusiast
Jump to solution

So I figured this out lol....

there are multiple interfaces that come back from the VM so I have to do something like the following.

$GuestInterface = Get-VMGuestNetworkInterface -VM "FITCCEM" | Select VM, IP, SubnetMask, DefaultGateway, Dns

ForEach($GuestIP in $GuestInterface)

{

  Write-Host $GuestIP.VM

  ForEach($DNS in $GuestIP.DNS)

  {Write-Host $DNS}

}

View solution in original post

0 Kudos
1 Reply
jmvirtual
Enthusiast
Enthusiast
Jump to solution

So I figured this out lol....

there are multiple interfaces that come back from the VM so I have to do something like the following.

$GuestInterface = Get-VMGuestNetworkInterface -VM "FITCCEM" | Select VM, IP, SubnetMask, DefaultGateway, Dns

ForEach($GuestIP in $GuestInterface)

{

  Write-Host $GuestIP.VM

  ForEach($DNS in $GuestIP.DNS)

  {Write-Host $DNS}

}

0 Kudos