So here is what I'm trying to do. I've seen other posts relating to this, but they only seem to get the immediate parent path rather than the full path. We've basically setup a tree structure like this:
DATA_Center\business_service\SLDC\VM (SLDC = Software Development Cycle)
We've set it up this way so it is easier for admins to find systems related to a particular business service. When a SAN maintenance occurs, we like to inform the business service admins affected by the maintenance. So we basically build a spreadsheet and find all the LUN's attached to that particular SAN, find the VM's, then lookup folder path the VM lies under to find what what business service is affected. I've attached a photo of our VC folder setup as an example.
I was wondering if it was possible through powershell to get a VM's associated folder path like what I have above. I'm able to grab all other information needed, except the folder path. Here is what I have so far:
Get-VM | % {Get-View $_.ID} |
select name,
@{ Name="Datastore";Expression={(Get-Datastore -VM $_.Name).Name}}
(All VMDK's for a server reside on the same datastore so I have no need to look for or list other datastores for a single VM)
I tried messing w/ the script in the below thread for folder pathing, but I can't seem to get what I'm looking for.