< Back
Get-View
Post
NAME Get-View
SYNOPSIS
This cmdlet returns the vSphere View objects that correspond to the specified search criteria.
SYNTAX
Get-View [-Filter <Hashtable>] [-Property <String[]>] [-SearchRoot <ManagedObjectReference>] [-Server
<VIServer[]>] -ViewType <Type> [<CommonParameters>]
Get-View [-Id] <ManagedObjectReference[]> [-Property <String[]>] [-Server <VIServer[]>] [<CommonParameters>]
Get-View [-Property <String[]>] -RelatedObject <ViewBaseMirroredObject[]> [<CommonParameters>]
Get-View [-VIObject] <VIObject[]> [-Property <String[]>] [<CommonParameters>]
DESCRIPTION
This cmdlet returns the vSphere View objects that correspond to the specified search criteria. The cmdlet
retrieves the vSphere View objects specified by their IDs or by their corresponding vSphere inventory objects
(VIObject). A View object ID is a <type>-<value> string. For objects with constant names such as AlarmManager and
ServiceInstance, the ID format is <type> (see the examples).
PARAMETERS
-Filter <Hashtable>
Specifies a hash of <name>-<value> pairs, where <name> represents the property value to test, and <value>
represents a regex pattern the property must match. If more than one pair is present, all the patterns must
match.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Id <ManagedObjectReference[]>
Specifies the IDs of the View objects you want to retrieve. A view object ID is a <type>-<value> string. For
objects with constant names such as AlarmManager and ServiceInstance, the ID format is <type> (see the
examples).
Note: When a list of values is specified for the Id parameter, the returned objects would have an ID that
matches exactly one of the string values in that list.
Required? true
Position? 1
Default value None
Accept pipeline input? False
Accept wildcard characters? true
-Property <String[]>
Specifies the properties of the view object you want to retrieve. If no value is given, all properties are
shown.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-RelatedObject <ViewBaseMirroredObject[]>
Specifies view-related objects to retrieve their views.
Required? true
Position? named
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? false
-SearchRoot <ManagedObjectReference>
Specifies a starting point for the search (in the context of the inventory).
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Server <VIServer[]>
Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is passed to this
parameter, the command runs on the default servers. For more information about default servers, see the
description of Connect-VIServer.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? true
-ViewType <Type>
Specifies the type of the View objects you want to retrieve. This parameter accepts ClusterComputeResource,
ComputeResource, Datacenter,Datastore, DistributedVirtualPortgroup, DistributedVirtualSwitch, Folder,
HostSystem, Network, OpaqueNetwork, ResourcePool,StoragePod, VirtualApp, VirtualMachine, and
VmwareDistributedVirtualSwitch values.
Required? true
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-VIObject <VIObject[]>
Specifies the vSphere managed object that corresponds to the View object you want to retrieve.
When you pass VIServer, Get-View returns ServiceInstance. When the retrieved View object is a ServiceInstance,
you cannot convert it to a VIObject with Get-VIObjectByVIView.
Required? true
Position? 1
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
Zero or more ViewBase objects
NOTES
-------------------------- Example 1 --------------------------
$vm = Get-View -ViewType VirtualMachine -Filter @{"Name" = "VM"}
$vmhostView = Get-View -ID $vm.Runtime.Host
$vmhostView.Summary.Runtime
Gets the VM virtual machine using a filter by name, populates the view object and retrieves the runtime
information.
-------------------------- Example 2 --------------------------
$folder = Get-Folder Folder | Get-View
Get-View -SearchRoot $folder.MoRef -ViewType "VirtualMachine"
Gets the view objects of virtual machines by specifying the root folder - MoRef.
-------------------------- Example 3 --------------------------
$folder = Get-Folder VM
$folderView = Get-View $folder -Property "[VirtualMachine]ChildEntity.Network.*"
$folderView.LinkedView.ChildEntity[0].LinkedView.Network
Gets the view of a folder by specifying for the Property parameter a property path, which leads to the networks of
the virtual machines in the specified folder. Retrieves the first of the returned networks.
-------------------------- Example 4 --------------------------
Connect-CIServer CloudServer1
Connect-VIServer VIServer1
$cloudExternalNetworkView = Get-ExternalNetwork ExternalNetwork1 | Get-CIView
Get-View -RelatedObject $cloudExternalNetworkView
Gets the view of a vSphere object related to the specified Cloud object. In this case, gets the vSphere port group
for the cloud external network.
RELATED LINKS
Online Version: https://code.vmware.com/doc/preview?id= ... -View.html
Get-VIObjectByVIView
SYNOPSIS
This cmdlet returns the vSphere View objects that correspond to the specified search criteria.
SYNTAX
Get-View [-Filter <Hashtable>] [-Property <String[]>] [-SearchRoot <ManagedObjectReference>] [-Server
<VIServer[]>] -ViewType <Type> [<CommonParameters>]
Get-View [-Id] <ManagedObjectReference[]> [-Property <String[]>] [-Server <VIServer[]>] [<CommonParameters>]
Get-View [-Property <String[]>] -RelatedObject <ViewBaseMirroredObject[]> [<CommonParameters>]
Get-View [-VIObject] <VIObject[]> [-Property <String[]>] [<CommonParameters>]
DESCRIPTION
This cmdlet returns the vSphere View objects that correspond to the specified search criteria. The cmdlet
retrieves the vSphere View objects specified by their IDs or by their corresponding vSphere inventory objects
(VIObject). A View object ID is a <type>-<value> string. For objects with constant names such as AlarmManager and
ServiceInstance, the ID format is <type> (see the examples).
PARAMETERS
-Filter <Hashtable>
Specifies a hash of <name>-<value> pairs, where <name> represents the property value to test, and <value>
represents a regex pattern the property must match. If more than one pair is present, all the patterns must
match.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Id <ManagedObjectReference[]>
Specifies the IDs of the View objects you want to retrieve. A view object ID is a <type>-<value> string. For
objects with constant names such as AlarmManager and ServiceInstance, the ID format is <type> (see the
examples).
Note: When a list of values is specified for the Id parameter, the returned objects would have an ID that
matches exactly one of the string values in that list.
Required? true
Position? 1
Default value None
Accept pipeline input? False
Accept wildcard characters? true
-Property <String[]>
Specifies the properties of the view object you want to retrieve. If no value is given, all properties are
shown.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-RelatedObject <ViewBaseMirroredObject[]>
Specifies view-related objects to retrieve their views.
Required? true
Position? named
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? false
-SearchRoot <ManagedObjectReference>
Specifies a starting point for the search (in the context of the inventory).
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Server <VIServer[]>
Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is passed to this
parameter, the command runs on the default servers. For more information about default servers, see the
description of Connect-VIServer.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? true
-ViewType <Type>
Specifies the type of the View objects you want to retrieve. This parameter accepts ClusterComputeResource,
ComputeResource, Datacenter,Datastore, DistributedVirtualPortgroup, DistributedVirtualSwitch, Folder,
HostSystem, Network, OpaqueNetwork, ResourcePool,StoragePod, VirtualApp, VirtualMachine, and
VmwareDistributedVirtualSwitch values.
Required? true
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-VIObject <VIObject[]>
Specifies the vSphere managed object that corresponds to the View object you want to retrieve.
When you pass VIServer, Get-View returns ServiceInstance. When the retrieved View object is a ServiceInstance,
you cannot convert it to a VIObject with Get-VIObjectByVIView.
Required? true
Position? 1
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
Zero or more ViewBase objects
NOTES
-------------------------- Example 1 --------------------------
$vm = Get-View -ViewType VirtualMachine -Filter @{"Name" = "VM"}
$vmhostView = Get-View -ID $vm.Runtime.Host
$vmhostView.Summary.Runtime
Gets the VM virtual machine using a filter by name, populates the view object and retrieves the runtime
information.
-------------------------- Example 2 --------------------------
$folder = Get-Folder Folder | Get-View
Get-View -SearchRoot $folder.MoRef -ViewType "VirtualMachine"
Gets the view objects of virtual machines by specifying the root folder - MoRef.
-------------------------- Example 3 --------------------------
$folder = Get-Folder VM
$folderView = Get-View $folder -Property "[VirtualMachine]ChildEntity.Network.*"
$folderView.LinkedView.ChildEntity[0].LinkedView.Network
Gets the view of a folder by specifying for the Property parameter a property path, which leads to the networks of
the virtual machines in the specified folder. Retrieves the first of the returned networks.
-------------------------- Example 4 --------------------------
Connect-CIServer CloudServer1
Connect-VIServer VIServer1
$cloudExternalNetworkView = Get-ExternalNetwork ExternalNetwork1 | Get-CIView
Get-View -RelatedObject $cloudExternalNetworkView
Gets the view of a vSphere object related to the specified Cloud object. In this case, gets the vSphere port group
for the cloud external network.
RELATED LINKS
Online Version: https://code.vmware.com/doc/preview?id= ... -View.html
Get-VIObjectByVIView