I am trying to use the example Change IP powershell on but keep getting the same error.
The term 'Find-EntityView' is not recognized as a cmdlet, function, operable program, or script file. Verify the term a nd try again.
Any better examples or can someone tell me what I may be missing? All I am changing from the Example is the values that is has in red.
Hi, there was some old stuff in the FAQ that I have just updated. Could you try again?
Tried the new sample, changing out he "<Target IP Address>" with the new IP and "Test" with the VM Name. Getting the following error.
Unexpected token 'vmclonespec' in expression or statement.
More Info
Believe i am running latest toolkit "VMware VI Toolkit for Windows 1.0 build 113525" is what is reported in ps.
Does anyone have a working example of change IP?
Hi There,
I'm also using this script to try and configure IP address on a newly deployed VM (powered off) and ran into this exception which looks like it happens after this line:
$vmmor.CloneVM_Task($target.MoRef ,$name, $vmclonespec )
Exception calling "CloneVM_Task" with "3" argument(s): "The operation is not supported on the object." At line:1 char:20 + $vmmor.CloneVM_Task <<<< ($target.MoRef ,$name, $vmclonespec ) + CategoryInfo : NotSpecified: ( [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException
Any ideas? I'm using this script and new to powershell and VI Toolkit
Thanks in advance!
That's a rather old post.
In the latest PowerCLI build you can find the Set-VMGuestNetworkInterface cmdlet.
Perhaps that could help you ?
Note that it only works for Windows 2003 and up and RHEL 5.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
Thanks for your reply
I downloaded and installed VMWare vSphere PowerCLI (VMware-Vim4PS-1.5.0-142961) on my PC running Windows 7 Enterprise which also has PowerShell included by Windows.
I open the "VI Toolkit", connect to the ESX host that is hosting the newly deployed VM as:
Connect-VIServer <server_name> -User <username> -Password <password>
But looks like the cmdlet "Set-VMGuestNetworkInterface" doesn't exist. I only see the combination of "Set-VMHost... " but not for "guest". Am I overlooking something? Or is it because I'm not running Windows 2003 or RHEL5? Please let me know.
Thanks,
donvito213
You installed an old version. The latest version is VMware-Vim4PS-4.0.1-208462. You can download it from http://www.vmware.com/go/powercli. If you have installed that version and run the cmdlet Get-PowerCLIVersion you should get the next output:
[vSphere PowerCLI] C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Get-PowerCLIVersion PowerCLI Version ---------------- VMware vSphere PowerCLI 4.0 U1 build 208462
Robert
Thanks Robert! I didn't realize I got an older version of PowerCLI; now I have the current version.
Now I'm able to see the cmdlet set-vmguestnetworkinterface but running into problems trying to configure an IP address to eth0 interface of a Linux VM that has eth0, eth1, and eth2 interfaces:
PS C:\Program Files\VMware\Infrastructure\VIToolkitForWindows> get-vm <*****> |
Get-VMGuestNetworkInterface -HostUser <***> -HostPassword <**> -GuestUser <***> -GuestPassword <*****>
VMId : VirtualMachine-368
SubnetMask :
NicId : VirtualMachine-368/4000
Name : eth0
IPPolicy : Dhcp
Ip :
Dns : {##.###.###.###, ##.##.##.##}
DefaultGateway :
Description : Ethernet
Mac : ######
RouteInterfaceId : eth0
DnsPolicy : Dhcp
WinsPolicy :
Wins :
VMId : VirtualMachine-368
SubnetMask :
NicId : VirtualMachine-368/4001
Name : eth1
IPPolicy : Dhcp
Ip :
Dns : {#######}
DefaultGateway :
Description : Ethernet
Mac : ######
RouteInterfaceId : eth1
DnsPolicy : Dhcp
WinsPolicy :
Wins :
VMId : VirtualMachine-368
SubnetMask :
NicId : VirtualMachine-368/4002
Name : eth2
IPPolicy : Dhcp
Ip :
Dns : {#####}
DefaultGateway :
Description : Ethernet
Mac : ######
RouteInterfaceId : eth2
DnsPolicy : Dhcp
WinsPolicy :
Wins :
VMId : VirtualMachine-368
SubnetMask : 255.0.0.0
NicId :
Name : lo
IPPolicy : Dhcp
Ip : 127.0.0.1
Dns : {######}
DefaultGateway :
Description : Local Loopback
Mac :
RouteInterfaceId : lo
DnsPolicy : Dhcp
WinsPolicy :
Wins :
PS C:\Program Files\VMware\Infrastructure\VIToolkitForWindows> Set-VMGuestNetwor
kInterface -VmGuestNetworkInterface eth0 -vm <***> -GuestUser <**> -GuestPassw
ord <***> -ip <***> -netmask <***> -gateway <****>
Set-VMGuestNetworkInterface : Cannot bind parameter 'VmGuestNetworkInterface'. Cannot convert the "eth0" value of type "System.String" to type "VMware.VimAuto mation.Types.VMGuestNetworkInterface". At line:1 char:53 + Set-VMGuestNetworkInterface -VmGuestNetworkInterface <<<< eth0 -vm <**> - GuestUser <**> -GuestPassword <**> -ip <*> -netmask <*> -gateway <**> + CategoryInfo : InvalidArgument: ( [Set-VMGuestNetworkInterfac e], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,VMware.VimAutomat ion.VimAutomation.Commands.SetVmGuestNetworkInterface
Anyone have any ideas how to resolve this exception? Thanks in advance!
There are more people with the same problem in thread . The cause of your problem might be that the networkinterface is not connected. Otherwise take a look at a different solution in this blogpost by Alan Renouf:
PowerCLI: Changing a VM IP Address with Invoke-VMScript.
Regards, Robert
Hi Robert,
Sorry for replying late. I am still strugglling to get this command to work without getting errors:
PS C:\Program Files\VMware\Infrastructure\VIToolkitForWindows> $vmGuestNetworkIn
terface = Get-VM <**> | `Get-VMGuestNetworkInterface -HostUser <****>-Host
Password <**> -GuestUser <*> -GuestPassword <**>| `Where-Object { $_
.Name -eq "eth0" }
WARNING: The version of VMware Tools on VM 'clayton-lnx' is out of date and may cause Copy-VMGuestFile to work improperly.
Get-VMGuestNetworkInterface : 4/30/2010 4:09:10 PM Get-VMGuestNetworkInterfa ce A6A57C46-E9EE-419D-B8FE-B2E745D28B2E Unable to parse script output.
At line:1 char:77 + $vmGuestNetworkInterface = Get-VM clayton-lnx | `Get-VMGuestNetworkInterface <<<< -HostUser root -HostPassword netscreen -GuestUser <****> -GuestPassword <***> | `Where-Object { $_.Name -eq "eth0" } + CategoryInfo : InvalidArgument: ( [Get-VMGuestNetworkInterfac e], ViError + FullyQualifiedErrorId : Client20_VmHostServiceImpl_GetVmGuestNetworkInte rface_UnableToParse,VMware.VimAutomation.VimAutomation.Commands.GetVmGuest NetworkInterface
Even running a more basic command still yields the same exact error of "Unable to parse script output":
PS C:\Program Files\VMware\Infrastructure\VIToolkitForWindows> Get-VM <*> | Get-VMGuestNetworkInterface -HostUser <*> -HostPassword <*> -GuestUser <*> -GuestPassword <**>
Any other ideas?
There are more people facing the same problem in thread . The cause of your problem might be that the networkinterface is not connected. Otherwise take a look at a different solution by Alan Renouf:
PowerCLI: Changing a VM IP Address with Invoke-VMScript.
Regards, Robert
Hi Robert,
I did check to ensure the VM has its network interface "connected" with the checkmark next to it. Also, I made sure the MAC address for eth0 was specified in the ifcfg-eth0 file as well but that did not work. I will check out the Invoke-VMScript. Thanks
There was one time I managed to get this working perfectly with a similar command below but now I'm getting a new error about "no such file/directory at /tmp/vmware0 line 31":
PS C:\Program Files\VMware\Infrastructure\VIToolkitForWindows> Get-VM sw5-3 | Ge t-VMGuestNetworkInterface -HostUser root -HostPassword <***> -GuestUser root -GuestPassword <***>| ? {$_.Name -eq "eth0"} | Set-VMGuestNetworkInterface -ip <IPADDR> -netmask <NETMASK> -gateway <GATEWAY>
WARNING: The version of VMware Tools on VM 'sw5-3' is out of date and may cause Copy-VMGuestFile to work improperly.
Get-VMGuestNetworkInterface : 5/5/2010 5:24:16 PM Get-VMGuestNetworkInterfac e A1868FB9-91A0-4942-B681-962448833706 Execution of the script in guest OS on VM 'sw5-3' failed: 'No such file or directory at /tmp/vmware0 line 31. ' At line:1 char:43 + Get-VM sw5-3 | Get-VMGuestNetworkInterface <<<< -HostUser root -HostPassword <PASSWORD> -GuestUser root -GuestPassword <PASSWORD| ? {$_.Name -eq "eth0"} | Set-VMGuestNetworkInterface -ip <IPADDR> -netmask <NETMASK> -gateway <GATEWAY> + CategoryInfo : InvalidData: (sw5-3:VirtualMachineImpl) [Get-VMG uestNetworkInterface], VimException + FullyQualifiedErrorId : Client20_RunScriptInGuestHelper_RunScriptFileInG uest_ScriptError,VMware.VimAutomation.VimAutomation.Commands.GetVmGuestNet workInterface