Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Just an addon. If you create a csv file like this
- name, IP
- vm1, 10.0.0.1
- vm2, 10.0.0.2
- vm3, 10.0.0.3
- Then create a script like this(just add the usual like connect-viserver etc):
- $Import = import-csv test.csv
- $Subnet = "255.255.255.0"
- $Gateway = "10.0.0.1"
- foreach ($VM in $Import)
- {
- write-host $VM.name and the IP is $VM.IP
- }
- You'll receive the output:
- PS C:\Users\userx\Desktop> .\testscript.ps1
- vm1 and the IP is 10.0.0.2
- vm2 and the IP is 10.0.0.3
- vm3 and the IP is 10.0.0.4
- Now change the write host part to include like this(add the guest credentials too). Note! I haven't tested this, but I don't think its far off.
- Invoke-VMScript -VM $VM.name -ScriptType bat -ScriptText netsh interface ip set address ""Local Area Connection"" static $VM.ip $Subnet $Gateway
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement