Hello all,
I'm brand new to scripting and I'm not sure why I seem to have to run these two commands separately:
get-vm "MYTESTVM" | Get-VMGuestNetworkInterface -Guestuser Administrator -GuestPassword MYPASSWORD |?{$_.name -eq "Local Area connection 4"} | set-vmguestnetworkinterface -Guestuser Administrator -GuestPassword MYPASSWORD -IPPolicy static -IP 10.244.186.113 -Netmask 255.255.255.0 -Gateway 10.244.186.1 -DNS 10.244.37.25,10.244.37.26
Get-NetworkAdapter "TEST-SVR01" | Set-NetworkAdapter -NetworkName VLAN186_QA -Confirm:$false
The code works if I run it line by line. But it doesn't work if I try this:
get-vm "MYTESTVM" | Get-VMGuestNetworkInterface -Guestuser Administrator -GuestPassword MYPASSWORD |?{$_.name -eq "Local Area connection 4"} | set-vmguestnetworkinterface -Guestuser Administrator -GuestPassword MYPASSWORD -IPPolicy static -IP 10.244.186.113 -Netmask 255.255.255.0 -Gateway 10.244.186.1 -DNS 10.244.37.25,10.244.37.26 | Get-NetworkAdapter "TEST-SVR01" | Set-NetworkAdapter -NetworkName VLAN186_QA -Confirm:$false
Any suggestions?
Thanks.