Last active
February 11, 2019 07:13
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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