Why is -MoRef needed in the script for setting up new virtual switches from the FAQ page? I guess I don't understand what -MoRef means. Could someone explain or point me to a document?
$HS = Find-EntityView -ViewType "HostSystem"
$nwSys = $HS.ConfigManager.NetworkSystem
$mor = Get-View -MoRef $nwSys
$networkConfig = New-Object Vmware.Vim.HostNetworkConfig
$vswtch = New-Object VMware.Vim.HostVirtualSwitchConfig
$networkConfig.vswitch = @($vswtch)
$networkConfig.vswitch[0].name = "SwitchName"
$spec = New-Object Vmware.Vim.HostVirtualSwitchSpec
$spec.numPorts = 1
$portgrp = New-Object VMware.Vim.HostPortGroupConfig
$networkConfig.portgroup = @($portgrp)
$portgropspec = New-Object VMware.Vim.HostPortGroupSpec
$portgropspec.vswitchName = "SwitchName"
$portgropspec.Name = "SwitchNamePort"
$portgropspec.Policy = New-Object VMware.Vim.HostNetworkPolicy
$networkConfig.vswitch[0].spec = $spec
$networkConfig.portgroup[0].spec = $portgropspec
$mor.AddVirtualSwitch("SwitchName",$spec ) $mor.AddPortGroup($portgropspec)
Thanks,
Jaime
MoRef stands for Managed Object Reference.
It is a pointer to the objects, also called inventory objects, that are the internal building blocks used by VI.
Attached to these objects are properties (data) and methods (functions) that allow one to manipulate (create, change, remove..) the objects.
The currently best explanation, till Hal's book is published , can be found in the SDK 2.5 Programming Guide in chapter 2 in the section titled Managed Object Types.
And there is of course the main page in the SDK 2.5 API reference that gives a good explanation.
That's the shortest description I could manage.
In the script you retrieve a pointer to the HostNetworkSystem via the HostSystem object.
You use the AddVirtualSwitch method that is available on a HostNetworkSystem object to create the virtual switch.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
MoRef stands for Managed Object Reference.
It is a pointer to the objects, also called inventory objects, that are the internal building blocks used by VI.
Attached to these objects are properties (data) and methods (functions) that allow one to manipulate (create, change, remove..) the objects.
The currently best explanation, till Hal's book is published , can be found in the SDK 2.5 Programming Guide in chapter 2 in the section titled Managed Object Types.
And there is of course the main page in the SDK 2.5 API reference that gives a good explanation.
That's the shortest description I could manage.
In the script you retrieve a pointer to the HostNetworkSystem via the HostSystem object.
You use the AddVirtualSwitch method that is available on a HostNetworkSystem object to create the virtual switch.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Cool, thanks for the explanation!