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.
The object that Set-VMGuestNetworkInterface places on the pipeline, is not an object that Get-NetworkAdapter expects on the pipeline.
The 1st cmdlet sends 1 or more VMGuestNetworkInterface objects.
The 2nd cmdlet expects a VM, Template or Related Object on the pipeline.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The object that Set-VMGuestNetworkInterface places on the pipeline, is not an object that Get-NetworkAdapter expects on the pipeline.
The 1st cmdlet sends 1 or more VMGuestNetworkInterface objects.
The 2nd cmdlet expects a VM, Template or Related Object on the pipeline.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
I believe I understand you. Are you saying that these two cmdlets cannot be run on the same line and need to be run seperately since they expect objects placed on the pipe?
Thanks.
Indeed.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference