14 Replies Latest reply on Jun 10, 2019 11:09 AM by aryajp

    How do i get MAC address and IP in a format i can use in a script

    dmacph Lurker


      Hi

       

      I want to collect the IP and MAC from a specific MV for use elsewhere.

       

      The 2 queries i have are

       

      Get-VM $VMname | Get-NetworkAdapter | select MacAddress

       

      Get-VM $VMname | Select @{N=”IP Address”;E={@($_.guest.IPAddress[0])}}

       

      They both return a header and the value

       

      IP Address

      ----------

      10.38.96.82

       

      I just want the value that i can stick in a variable for use elsewhere - like so

       

      $VMmac = (Get-VM $VMname | Get-NetworkAdapter | select MacAddress )

       

      What simple thing am i missing?

       

      Assistance much appreciated