PowerCLI Reference

Get-Folder

Synopsis

This cmdlet retrieves the folders available on a vCenter Server system.

Syntax

Get-Folder [-Location <VIContainer[]>] [-Type <FolderType[]>] [-Tag <Tag[]>] [-Server <VIServer[]>] [[-Name] <String[]>] [-NoRecursion] [<CommonParameters>]

Get-Folder [-RelatedObject] <FolderRelatedObjectBase[]> [<CommonParameters>]

Get-Folder [-Server <VIServer[]>] -Id <String[]> [<CommonParameters>]

Related Commands

Online version
New-Folder
Remove-Folder
Set-Folder
Move-Folder

Detailed Description

This cmdlet retrieves the folders available on a vCenter Server system. The cmdlet returns a set of folders that correspond to the filter criteria provided by the cmdlet parameters. To specify a server different from the default one, use the Server parameter.

Parameters

NameTypeDescriptionRequired?Pipeline InputDefault Value
NameString[]Specifies the names of the folders you want to retrieve.falsefalse
RelatedObjectFolderRelatedObjectBase[]Specifies objects to retrieve one or more Folder objects that are related to them. This parameter accepts OMResource? objects.truetrue (ByValue)
IdString[]Specifies the IDs of the folders you want to retrieve.

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.
truefalse
LocationVIContainer[]Specifies vSphere container objects (folders, datacenters, or clusters) you want to search for folders.falsetrue (ByValue)
NoRecursionSwitchParameterIndicates that you want to disable the recursive behavior of the command.falsefalse
ServerVIServer[]Specifies the vSphere servers on which you want to run the cmdlet. If no value is given to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-VIServer.falsefalse
TagTag[]Returns only the folders that are associated with any of the specified tags.falsefalse
TypeFolderType[]Specifies the type of the folders you want to retrieve. The valid values are VM, HostAndCluster, Datastore, Network, and Datacenter.falsefalse

Return Type

Zero or more Folder objects

Notes

Examples

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

$server = Connect-VIServer -Server 10.23.112.235

Get-Folder -Server $server -Name Folder

Retrieves the folder named Folder on the server with IP address 10.23.112.235.

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

Get-Folder -NoRecursion

Retrieves the root folder.

-------------- Example 3 --------------

Get-Folder -Location $folder

Gets all folders in the specified location.

-------------- Example 4 --------------

$folder = Get-Folder | Select -first 1

Get-Folder -ID $folder.ID

Gets a folder by ID.

-------------- Example 5 --------------

Get-Folder -Type Network

Gets all network folders.


Copyright © VMware, Inc. All rights reserved.