The other day I found a piece of code to query vCenter configuration:
Get-View -Id 'OptionManager-VpxSettings'
I was wondering what else can be passed to -Id parameter. Is there any documentation that lists other possibilities?
Hello, jl999-
In general, the ID of any vSphere object can be passed as a value to the -Id parameter of Get-View.
As for the the "built-in" ID that you mention -- yes, there is documentation about the other available default IDs. You can list them by checking out the $global:DefaultServer automatic variable, looking at its Content property. Like:
## access the Content property of the default VIServer's managed object
$global:DefaultVIServer.ExtensionData.Content
This should return something like
RootFolder : Folder-group-d1 PropertyCollector : PropertyCollector-propertyCollector ViewManager : ViewManager-ViewManager About : VMware.Vim.AboutInfo Setting : OptionManager-VpxSettings UserDirectory : UserDirectory-UserDirectory SessionManager : SessionManager-SessionManager AuthorizationManager : AuthorizationManager-AuthorizationManager ServiceManager : PerfManager : PerformanceManager-PerfMgr ScheduledTaskManager : ScheduledTaskManager-ScheduledTaskManager AlarmManager : AlarmManager-AlarmManager EventManager : EventManager-EventManager TaskManager : TaskManager-TaskManager ExtensionManager : ExtensionManager-ExtensionManager CustomizationSpecManager : CustomizationSpecManager-CustomizationSpecManager CustomFieldsManager : CustomFieldsManager-CustomFieldsManager AccountManager : DiagnosticManager : DiagnosticManager-DiagMgr LicenseManager : LicenseManager-LicenseManager SearchIndex : SearchIndex-SearchIndex FileManager : FileManager-FileManager VirtualDiskManager : VirtualDiskManager-virtualDiskManager VirtualizationManager : SnmpSystem : HostSnmpSystem-SnmpSystem VmProvisioningChecker : VirtualMachineProvisioningChecker-ProvChecker VmCompatibilityChecker : VirtualMachineCompatibilityChecker-CompatChecker OvfManager : OvfManager-OvfManager IpPoolManager : IpPoolManager-IpPoolManager DvSwitchManager : DistributedVirtualSwitchManager-DVSManager HostProfileManager : HostProfileManager-HostProfileManager ClusterProfileManager : ClusterProfileManager-ClusterProfileManager ComplianceManager : ProfileComplianceManager-MoComplianceManager LocalizationManager : LocalizationManager-LocalizationManager StorageResourceManager : StorageResourceManager-StorageResourceManager GuestOperationsManager : GuestOperationsManager-guestOperationsManager ...
An alternative that should get you the same: use Get-View on the root of the vSphere inventory, the "ServiceInstance" (note that is _instance_, not _content_):
## get the inventory root object, and access its Content property
(Get-View ServiceInstance).Content
The properties of the resulting ServiceContent object are documented at http://pubs.vmware.com/vsphere-51/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc%2Fvim.ServiceInstan....
And, not to confuse the situation, but the documentation for the inventory root object, ServiceInstance, is at http://pubs.vmware.com/vsphere-51/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc%2Fvim.ServiceInstan....
Of course, it is a good idea to get the latest (or specific) documentation for the version of API that you are using, available at VMware's vSphere Web Services SDK documentation page.
That do it?
Thanks Matt. That's exactly what I'm looking for.
Discussion moved from vCenter Update Manager PowerCLI to VMware vSphere™ PowerCLI.
This would probably be helpful as well..
http://pubs.vmware.com/vsphere-51/topic/com.vmware.wssdk.apiref.doc/index-mo_types.html
I guess VMware has been replacing Get-View with .ExtensionData. But in some cases it still requires to use Get-View.
Using Matt's example, these are identical:
$global:DefaultViServer.ExtensionData.Content
(Get-View ServiceInstance).Content
But when I try to get the vCenter configuration settings, I have to use:
(Get-View 'OptionManager.VpxSettings').Setting
or
(Get-View $global:DefaultVIServer.ExtensionData.Content.Setting).Setting
But I cannot drill through like this:
$global:DefaultVIServer.ExtensionData.Content.Setting.ExtensionData.Setting
To me, this way would be more logical and more consistent.
Your thoughts?
Jason
It probably depends on the way each one of us sees the use of links and property mappings, but to me that difference you point out "looks" logical.
The ExtensionData property is a property, that was added by the PowerCLI Dev team, to have quick access to the underlying vSphere object.
On top of that they introduced some serious performance gains by only fetching what you actually access.
The ServiceInstance.Content.Setting property is a property that is present in the vSphere ServiceInstance object (nothing to do with PowerCLI) and that actually contains a MoRef to another object. To simplify I consider a MoRef as a kind of pointer.
To get the object a MoRef 'points' you have to use the Get-View cmdlet.
So this
(Get-View $global:DefaultVIServer.ExtensionData.Content.Setting).Setting
looks quite natural to me.
There is a way to access the OptionManager object in a sort of way like you suggest.
It involves the use of the UpdateViewData method and the LinkedView property.
$si = $global:DefaultVIServer.ExtensionData
$si.UpdateViewData("Content.Setting.*")
$si.Content.LinkedView.Setting
There is some info on this method in Optimize the performance of PowerCLI’s views.
But while this might look rather intuitive to a developer, I personally think this is way beyond what a vSphere administrator sees as "natural" :smileygrin:
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference