Automation

 View Only
  • 1.  Template Location - PowerCLI

    Broadcom Employee
    Posted Jun 18, 2013 12:55 PM

    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,



  • 2.  RE: Template Location - PowerCLI

    Posted Jun 18, 2013 03:07 PM

    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

    [...]



  • 3.  RE: Template Location - PowerCLI

    Broadcom Employee
    Posted Jun 18, 2013 03:31 PM

    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,



  • 4.  RE: Template Location - PowerCLI

    Posted Jun 18, 2013 03:34 PM

    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



  • 5.  RE: Template Location - PowerCLI
    Best Answer

    Posted Jun 18, 2013 04:07 PM

    Try like this

    Get-Template |
    Select Name,@{N="Datastore";E={[string]::Join(',',(Get-View $_.DatastoreIdList | %{$_.Name}))}}


  • 6.  RE: Template Location - PowerCLI

    Broadcom Employee
    Posted Jun 19, 2013 12:07 PM

    Hi MKGuy,

    I am using PowerCLI 4.1

    Hi Luc

    As always .. you are the Man! :smileyhappy: your one liner worked perfect. thank you and full marks.



  • 7.  RE: Template Location - PowerCLI

    Posted Jun 19, 2013 01:25 PM

    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