VMware Cloud Community
chicojr
Enthusiast
Enthusiast
Jump to solution

get-vmnetwork

what command can I utilize to obtain all local area connection information on a nic such as default gateway/dns servers

Reply
0 Kudos
1 Solution

Accepted Solutions
Gidrakos
Hot Shot
Hot Shot
Jump to solution

Marmotte94, the Get-VMGuestNetworkInterface will push local credentials if you don't specify anything, and in the event that those credentials do not work, you can accomplish everything with this one line:

$cred = Get-Credential; Get-VMGuestNetworkInterface vm-name -guestCredential $cred

If you need to specify host credentials, you can do the same thing but specify the -HostCredential parameter.

View solution in original post

Reply
0 Kudos
12 Replies
Gidrakos
Hot Shot
Hot Shot
Jump to solution

You used to be able to use Get-VMGuestNetworkInterface which would return a VMGuestNetworkInterface object containing the info you want, but VMware has deprecated this call.

They now recommend you use Invoke-VMScript which will let you run a script (defaulted to either Powershell or Bash depending on the OS).

If your VM is Windows, you'd want something like this: Invoke-VMScript -vm [vm name] "ipconfig /all"

Hope this helps! Smiley Happy

Reply
0 Kudos
Marmotte94
Enthusiast
Enthusiast
Jump to solution

Hi,

I wrote a script to add some function in PowerCLI to search any gateway for VM as you want.

You can find it at this URL : On the road again.. - PurpleScreen.eu

if you need more informations, you can send me an email from this Blog.

Thank you,

Olivier.

Please, visit my blog http://www.purplescreen.eu/
Reply
0 Kudos
chicojr
Enthusiast
Enthusiast
Jump to solution

12-6-2017 1-10-26 PM.png

I get this error when running your command.

Reply
0 Kudos
chicojr
Enthusiast
Enthusiast
Jump to solution

Olivier, the link takes me to the site but isn't in english.

Reply
0 Kudos
Marmotte94
Enthusiast
Enthusiast
Jump to solution

Hi,

You have to run this command in PowerCLI as well as connect to your vCenter server.

Thank you,

Olivier

Please, visit my blog http://www.purplescreen.eu/
Reply
0 Kudos
Marmotte94
Enthusiast
Enthusiast
Jump to solution

Year Sorry, but I had develop it in English.

Please, visit my blog http://www.purplescreen.eu/
Reply
0 Kudos
Gidrakos
Hot Shot
Hot Shot
Jump to solution

Hello chicojr

You'll need to remove the brackets "[ ]" from the VM name - I was using them as a placeholder. The "-vm" parameter accepts a string of the vm's name.

Reply
0 Kudos
chicojr
Enthusiast
Enthusiast
Jump to solution

that will work, and appreciate it but now is there anyway to get past this:

12-7-2017 8-40-57 AM.png

Reply
0 Kudos
Gidrakos
Hot Shot
Hot Shot
Jump to solution

It seems like you're running a fairly old version of VMTools then. What operating system are you trying to run this on?

If it's Windows Server 2003 then the Get-VMGuestNetworkInterface command will work for you like this (I just tested it):

PS C:\Windows\system32> Get-VMGuestNetworkInterface vm-name

VM              Name                      IP              IPPolicy   SubnetMask

--              ----                      --              --------   ----------

vm-name      Local Area Connection 3   x.x.x.x      Dhcp       255.255.0.0

Unfortunately, according to VMware documentation, and my own testing, that command only works on Windows XP, Server 2003, and RHEL 5. You may need to upgrade your VMTools if you'd like to properly utilize the Invoke functionality.

Reply
0 Kudos
Marmotte94
Enthusiast
Enthusiast
Jump to solution

You are forgot the Credential for this VM.

Take a look on this post Uninstalling vmtools

I wrote a script with IPConfig

Thank you,

Please, visit my blog http://www.purplescreen.eu/
Reply
0 Kudos
Gidrakos
Hot Shot
Hot Shot
Jump to solution

Marmotte94, the Get-VMGuestNetworkInterface will push local credentials if you don't specify anything, and in the event that those credentials do not work, you can accomplish everything with this one line:

$cred = Get-Credential; Get-VMGuestNetworkInterface vm-name -guestCredential $cred

If you need to specify host credentials, you can do the same thing but specify the -HostCredential parameter.

Reply
0 Kudos
Marmotte94
Enthusiast
Enthusiast
Jump to solution

Hi,

I think it better used a scalable issu like Invoke-VMScript. It's better. But It's my opinion. Get-VMGuestNetworkInterface doesn't work for all systems.

Source :

Get-VMGuestNetworkInterface - vSphere PowerCLI Cmdlets Reference

Invoke-VMScript

Thank you,

Regards,

Please, visit my blog http://www.purplescreen.eu/
Reply
0 Kudos