Get-VaultFolders
Retrieves specific folders from Vault.
Syntax
Get-VaultFolders [-Path] <String> [-Recursive] [<CommonParameters>]
Get-VaultFolders [-Properties] <Hashtable> [<CommonParameters>]
Parameters
Type |
Name |
Description |
Optional |
---|---|---|---|
String |
Path |
Path of parent folder to get subfolders of |
no |
SwitchParameter |
Recursive |
Get all levels of subfolders recursively |
yes (only available with the -Path parameter) |
Hashtable |
Properties |
Search whole Vault for Folders matching passed properties |
no |
Return type
Folder[] ← on success
empty ← on failure
Remarks
The -Properties parameter allows to search for folders that match all the passed properties and their values (system properties and UDPs are supported).
In the passed Hashtable the keys represent the property names and the values represent the searched property values.
When no matching folders are found the cmdlet returns empty.
When no folder property exists in Vault for a passed property name, it is ignored in the search.
Folders that are missing searched properties (property not assigned), will be ignored.
When the -Recursive parameter is used, all folders and subfolders are returned as a flat list.
Examples
Get Child folders in a specific Vault path
$folders = Get-VaultFolders -Path '$/Designs'
Get folders matching specific properties:
$folders = Get-VaultFolders -Properties @{
"Category Name" = "ProjectFolder";
"ProjectNumber" = 100; # UDP
}
Retrieve all folders recursively:
$allFoldersInVault = Get-VaultFolders -Path '$' -Recursive
foreach($folder in $allFoldersInVault) {
"Folder: $($folder._FolderPath)"
}
Search folders older than 8 months in a specific Vault path:
# Checking the existence of a Vault folder based on its path
$folder = Get-VaultFolder -Path '$/Designs/'
if(-not $folder) {
Write-Error 'the Vault folder does not exist'
}
# Get a list of folders in a specific Vault folder (one level, no recursive subfolders)
$subFolders = Get-VaultFolders -Path '$/Designs/'
# Filter folders by Create Date
$subFoldersCreatedMoreThan8MonthsAgo = $subFolders | Where-Object { $_.'Create Date (Date Only)' -lt ((Get-Date).AddMonths(-8)) }