Hello,
Is there any powercli script that can generate the list of templates and their Datastore name where they are residing? I only need these two properties.
Thank you,
Try like this
Get-Template |
Select Name,@{N="Datastore";E={[string]::Join(',',(Get-View $_.DatastoreIdList | %{$_.Name}))}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The following snippet will list all templates and their datastores:
Get-Template | Select -Property Name, @{N="Datastore";E={(Get-Datastore -Id $_.DatastoreIdList).Name}} | FT -autosize
Name Datastore
---- ---------
Template_1 Datastore5
Template_2 Datastore5
Template_3 Datastore6
[...]
thanks MKguy,
This script ran fine but unfortunately it did not give the Datastore names. It only gave the Template names.
something missing?
thanks again,
Which PowerCLI version are you running? I have no problem getting the Datastore names with the latest version 5.1 R2:
https://my.vmware.com/group/vmware/get-download?downloadGroup=VSPS510-PCLI-510R2
Get-PowerCLIVersion
PowerCLI Version
----------------
VMware vSphere PowerCLI 5.1 Release 2 build 1012425
Try like this
Get-Template |
Select Name,@{N="Datastore";E={[string]::Join(',',(Get-View $_.DatastoreIdList | %{$_.Name}))}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi MKGuy,
I am using PowerCLI 4.1
Hi Luc
As always .. you are the Man! your one liner worked perfect. thank you and full marks.
Cool if it works with Lucs script. Just one thing to note: You can use the latest PowerCLI even with 4.x based vCenter/ESXi servers, so there isn't really any reason to not upgrade considering PowerCLI 5.1 R2 contains goodies like dvSwitch and Powershell 3.0 support.
http://www.vmware.com/support/developer/PowerCLI/PowerCLI51R2/powercli51r2-releasenotes.html
VMware vSphere PowerCLI 5.1 Release 2 supports the following VMware environments:
- vCenter Server 5.1.0a
- VMware ESXi 5.1.0a
- vCenter Server 5.0 Update 2
- VMware ESXi 5.0 Update 2
- vCenter Server 4.1 Update 3
- VMware ESXi 4.1 Update 3
- VMware ESX 4.1 Update 3
- vCenter Server 4.0 Update 4
- VMware ESX 4.0 Update 4
- VMware ESX 4.0i Update 4