Skip to content

Instantly share code, notes, and snippets.

@skunkie
Last active February 11, 2019 07:13
Show Gist options
  • Save skunkie/5e9ff02dc835181a500dcc855127a7be to your computer and use it in GitHub Desktop.
Save skunkie/5e9ff02dc835181a500dcc855127a7be to your computer and use it in GitHub Desktop.
This cmdlet retrieves the path to the folder on a vCenter Server system.
function Get-FolderPath {
<#
.NAME
Get-FolderPath
.SYNOPSIS
This cmdlet retrieves the path to the folder on a vCenter Server system.
.DESCRIPTION
This cmdlet retrieves the path to the folder on a vCenter Server system.
.PARAMETER Folder
a folder on a vCenter Server system
.EXAMPLE
Get-Folder | Get-FolderPath
.LINK
https://gist.github.com/skunkie/5e9ff02dc835181a500dcc855127a7be
.NOTES
Last modified: 11.02.2019
#>
param (
# VM Folder
[Parameter(Mandatory=$true, ValueFromPipeline)]
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl]
$Folder
)
Process {
$ret = [PSCustomObject]@{
Folder = $Folder
Path = @()
}
do {
$ret.Path += $Folder
$Folder = $Folder.Parent
} while ($Folder.Parent -ne $null)
[array]::Reverse($ret.Path)
$ret
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment