VMware Cloud Community
Mark_Josepher
Contributor
Contributor
Jump to solution

Get full folder path for Templates

Hello

I am trying to solve a issue that we have in our environment.

We have massive template sprawl and  I am trying to get the full path to every template that we have.  There is a very nice function that does this for VM's but nothing is out there for templates and modifying it  to accept get-view doesn't work.

I was wondering if any one else has run into this and has a nice way to get the information out with powercli.

Thanks

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Which function are you referring to?

You can have a look at my Get-InventoryPlus – Inventory of all vSphere objects, it should also return templates


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

5 Replies
Prakas
Enthusiast
Enthusiast
Jump to solution

Did you try the "Get-Template" cmdlet?

Reply
0 Kudos
Mark_Josepher
Contributor
Contributor
Jump to solution

Yes I did, it doesn't have the same behavior has the get-vm and therefore does not return the same values.

Thanks

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Which function are you referring to?

You can have a look at my Get-InventoryPlus – Inventory of all vSphere objects, it should also return templates


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Mark_Josepher
Contributor
Contributor
Jump to solution

Thanks this looks very promising

it gets me everything but I was looking for a little more granular.  We have over 8000 vm's and templates in each of our vc's, some of them with a lot more and hundreds of hosts.

The only thing that would be nice is if it took a location to run from as a parameter.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You can change line 155

$contView = $viewMgr.CreateContainerView($si.Content.RootFolder,$null,$true)

into

$folder = Get-Folder -Name 'MyFolder'

$contView = $viewMgr.CreateContainerView($folder.ExtensionData.MoRef,$null,$true)

That way the inventory will start in the folder called 'MyFolder' instead of the vSPhere rootfolder


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference