VMware {code} Community
gilesm
Contributor
Contributor
Jump to solution

Retrieving a VM or Host "path"

I need to know the full "path" to a VM or Host as it appears in the "Virtual Machines and Templates" view in the vSphere client. Right now, my C# code uses recursion to walk through and build each path individually. For a large environment (500+ VMs) this process takes an extremely long time. I realize the recursion is the problem but am curious if anyone has figured out a more efficient way to collecting a VM or Host's path? Thanks and I've provided a sample below to show what I want to retrieve.

"Atlanta/Development/Mike/MyVM01"

  • "Atlanta" is the datacenter

  • "Development" is a folder under the "Atlanta"datacenter.

  • "Mike" is a folder underneath the "Development" folder.

  • "MyVM01" is the actual virtual machine display name.

0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager
Jump to solution

Take a look at this script: you can easily modify the script to change the way it's outputted to what you like.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

Twitter: @lamw

If you find this information useful, please award points for "correct" or "helpful".

View solution in original post

0 Kudos
2 Replies
lamw
Community Manager
Community Manager
Jump to solution

Take a look at this script: you can easily modify the script to change the way it's outputted to what you like.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

Twitter: @lamw

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
gilesm
Contributor
Contributor
Jump to solution

I figured we could not get away from using recursion so I guess I'm just stuck with that. Thanks for the help.

0 Kudos