Hi,
Have only started playing with the vi toolkit / powershell in the last couple of days and am really enjoying it! After playing around with lots of scripts I am starting to write my own automation script for setting up new hosts. I am doing ok but have got stuck with this command.
If I type
new-vmhostnetwork adapter -vmhost testhost.demo -virtualswitch iscsi -portgroup vmkernel -ip 172.16.100.1 -subnetmask 255.255.255.0
I get the following error
New-VMHostNetworkAdapter : Cannot bind parameter 'VirtualSwitch'. Cannot convert value "iscsi" to type "VMware.VimAutomation.Types.Host.VirtualSwitch". Error: "Invalid cast from 'System.String' to 'VMware.VimAutomation.Types.Host.VirtualSwitch'."
I'm probably mis-understanding part of the help.
Cheers
Barry
VCP
Hi Barry, you've stumbled across an inconsistency in the toolkit.
Many objects can be identified simply by name. For instance, you can say New-VM -Datastore mydatastore and the proper datastore will be used.
There are some objects that do not support this. Unfortunately VirtualSwitch is one of them. I believe PortGroup is as well.
To deal with this, use this pattern:
-virtualswitch (get-virtualswitch iscsi)
-portgroup (get-virtualportgroup mygroup)
This behavior is going to improve in future versions of the toolkit, but this is the way to go for now.
Hi Barry, you've stumbled across an inconsistency in the toolkit.
Many objects can be identified simply by name. For instance, you can say New-VM -Datastore mydatastore and the proper datastore will be used.
There are some objects that do not support this. Unfortunately VirtualSwitch is one of them. I believe PortGroup is as well.
To deal with this, use this pattern:
-virtualswitch (get-virtualswitch iscsi)
-portgroup (get-virtualportgroup mygroup)
This behavior is going to improve in future versions of the toolkit, but this is the way to go for now.
Worked a treat, many thanks
VCP