powershellscripts.com

Tutorials  PowerShell Cmdlet Help for Get-View



NAME
Get-View

SYNOPSIS
Returns the vSphere .Net view objects that correspond to the specified search criteria.

SYNTAX
Get-View [-VIObject] [-Property ] []

Get-View [-Server ] [-Id] [-Property ] []

Get-View [-Server ] [-SearchRoot ] -ViewType [-Filter ] [-Pro
perty ] []

Get-View [-Property ] -RelatedObject []


DESCRIPTION
Returns the vSphere .Net view objects that correspond to the specified search criteria. The cmdlet retrieves the vS
phere .NET view objects specified by their IDs or by their corresponding vSphere inventory objects (VIObject). A vi
ew object ID is a - string. For objects with constant names such as AlarmManager and ServiceInstance,
the ID format is (see the examples).


PARAMETERS
-VIObject
Specify the corresponding vSphere managed object of the .NET view object you want to retrieve.

Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false

-Property
Specify 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
Accept pipeline input? false
Accept wildcard characters? false

-Server
Specify the vSphere servers on which you want to run the cmdlet. If no value is given to this parameter, the co
mmand runs on the default servers. For more information about default servers, see the description of Connect-V
IServer.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? true

-Id
Specify the IDs of the .NET View objects you want to retrieve. A view object ID is a - string. For
objects with constant names such as AlarmManager and ServiceInstance, the ID format is (see the example
s).

Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? true

-SearchRoot
Specify a starting point for the search (in the context of the inventory).

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-ViewType
Specify the type of the view objects you want to retrieve.

Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Filter
Specify a hash of - pairs, where represents the property value to test, and represe
nts a pattern the property must match. If more than one pair is present, all the patterns must match.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-RelatedObject
Specify view-related objects to retrieve their views.

Required? true
Position? named
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false


This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

INPUTS



OUTPUTS
VMware.Vim.ViewBase or VMware.Vim.EntityViewBase


NOTES




-------------- Example 1 --------------

C:\PS>$vm = Get-View -ViewType VirtualMachine -Filter @{"Name" = "VM"}

$hostView = Get-View -ID $vm.Runtime.Host

$hostView.Summary.Runtime


Gets the VM virtual machine using a filter by name, populates the view object and retrieves the runtime information
.





-------------- Example 2 --------------

C:\PS>$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 --------------

C:\PS>$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 --------------

C:\PS>Connect-CloudServer CloudServer1

Connect-VIServer VIServer1

$cloudExternalNetworkView = Get-CloudExternalNetwork ExternalNetwork1 | Get-CloudView

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: http://www.vmware.com/support/developer/PowerCLI/PowerCLI501/html/Get-View.html
Get-VIObjectByVIView