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

Re: change ip address of all vms

$
0
0

Thanks LucD - that did it using GuestUser and GuestPassword.  Now have a working script that uses the invoke-vmscript CMDlet that draws the servers to configure from a CSV file that contains names and IPs, the gateway and mask are always the same in my case so I have removed them from Virtu-AL's script example and have replaced them with variables so that they don't need to be entered into the CSV.

 

Now I have seen where others have used variables for these parameters, for example,

 

$GU = "administrator"

$GP = "'password$$$'" (note I have a set of single quotes because the pw has special charater)

 

-GuestUser $GU -GuestPassword $GP

 

I have replace the typed user and pw with these variables, and the instant I do this the script no longer works.

 

I am trying to use the $GU and $GP in Virtu-AL's function Set-WinVMIP as well as lower in the script where the function is executed.. something is wrong..

 

Function Set-WinVMIP ($VM, $IP, $SNM, $GW){

$netsh = "c:\windows\system32\netsh.exe interface ip set address ""Local Area Connection 3"" static $IP $SNM $GW 1"

Write-Host "Setting IP address for $VM..."

Invoke-VMScript -VM $VM -GuestUser $GU -GuestPassword $GP -ScriptType bat -ScriptText $netsh

Write-Host "Setting IP address completed."

}

 

# and farther down I use it here:

 

Set-WinVMIP $VM -GuestUser $GU -GuestPassword $GP $_.IP $SNM $GW


Viewing all articles
Browse latest Browse all 229247

Trending Articles



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