Advertisement
Guest User

powercli

a guest
Mar 28th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. Just an addon. If you create a csv file like this
  2. name, IP
  3. vm1, 10.0.0.1
  4. vm2, 10.0.0.2
  5. vm3, 10.0.0.3
  6.  
  7. Then create a script like this(just add the usual like connect-viserver etc):
  8. $Import = import-csv test.csv
  9. $Subnet = "255.255.255.0"
  10. $Gateway = "10.0.0.1"
  11. foreach ($VM in $Import)
  12. {
  13. write-host $VM.name and the IP is $VM.IP
  14. }
  15. You'll receive the output:
  16. PS C:\Users\userx\Desktop> .\testscript.ps1
  17. vm1 and the IP is 10.0.0.2
  18. vm2 and the IP is 10.0.0.3
  19. vm3 and the IP is 10.0.0.4
  20.  
  21. 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.
  22. 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