VMware Cloud Community
tdubb123
Expert
Expert
Jump to solution

invoke-vmscript error

trying to change dns settings on vm

but getting this error

$script2 = netsh interface ip add dns 'Local Area Connection' 10.50.1.55

any idea?Capture.JPG

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Does it work when you explicitly add credentials (GuestUser/GuestPassword or GuestCredential) for the guest OS ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
7 Replies
LucD
Leadership
Leadership
Jump to solution

Does it work when you explicitly add credentials (GuestUser/GuestPassword or GuestCredential) for the guest OS ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
tdubb123
Expert
Expert
Jump to solution

yes it does

thanks luc

Reply
0 Kudos
tdubb123
Expert
Expert
Jump to solution

luc

Is it possible to change ip address, sm, gw, dns1, dns2  from a bat file?

I have a bat file like

netsh interface ip set address "Local Area Connection" static 10.50.2.10 255.255.0.0 10.50.0.1

netsh interface ip add dns "Local Area Connection" 10.50.1.55

netsh interface ip add dns "Local Area Connection" addr=10.50.1.56 index=2

or do I need to do it via 3 invoke-vmscript commands?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

No, you can do that in 1 call to Invoke-VMScript.

I normally use a here-string when I have multiple lines, something like this

$cmd = @'

netsh interface ip set address "Local Area Connection" static 10.50.2.10 255.255.0.0 10.50.0.1

netsh interface ip add dns "Local Area Connection" 10.50.1.55

netsh interface ip add dns "Local Area Connection" addr=10.50.1.56 index=2

'@

Invoke-VMScript -VM $vm -ScriptText $cmd -ScriptType Bat


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
tdubb123
Expert
Expert
Jump to solution

thank Lucd

It ran fine and mde the changes but I saw this output

Screen Shot 2015-07-28 at 7.37.27 AM.png

both DNs got changed fine though.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Those messages come from the netsh command, by default it tries to see if the DNS server exists.

Add "validate=no" at the end of the netsh command.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
tdubb123
Expert
Expert
Jump to solution

Thanks Luc

Reply
0 Kudos