Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 231085

Re: Powecli set IP for a Windows virtual machine from IP pool

$
0
0

This is the code to fetch IP from XML and set to NIC,

I have vmtoolsd.exe in my windows environment path variable.

I have four dynamic properties defined IP, Mask, Gateway and DNS.

 

$command = @'
cmd.exe /C vmtoolsd.exe --cmd "info-get guestinfo.ovfEnv" > C:\temp\poolip.txt
'@
Invoke-Expression -Command:$command
$cont = @()
$cont = Get-Content c:\temp\poolip.txt
$regex = [regex] "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"
$ips = $regex.matches($cont)
$dns = $ips[0].value
$ipaddr = $ips[1].value
$mask = $ips[2].value
$gateway = $ips[3].value
Invoke-command{
netsh interface ip set address "Local Area Connection" static $ipaddr $mask $gateway
netsh interface ip add dns "Local Area Connection" $dns}

 

Thanks Again!


Viewing all articles
Browse latest Browse all 231085

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>