VMware Cloud Community
Sunshine_S
Enthusiast
Enthusiast

New-ContentLibraryItem : Example given on developer.vmware.com is not working

I want to add 30 local templates to content library. So I am trying to do this using PowerCLI. My attempts were failing so I used the example directly. (changed the names of template and library of-course)

https://developer.vmware.com/docs/powercli/latest/vmware.vimautomation.core/commands/new-contentlibr...

Example 6

$template = Get-Template -Name 'MyTemplate'
$localContentLibrary = Get-ContentLibrary -Name 'Local content library' -Local
New-ContentLibraryItem -ContentLibrary $localContentLibrary -Name 'OVF template library item' -Template $template
 
Instead of MyTemplate, I have put in the actual template name
Instead of 'Local Content Library', the name of my library
Instead of 'OVF template library item', the required name
 
But I keep getting the same error:
New-ContentLibraryItem : A parameter cannot be found that matches parameter name 'Template'.
 
What am I doing wrong?
These commands are straight from VMware.
Labels (3)
Tags (1)
Reply
0 Kudos
5 Replies
LucD
Leadership
Leadership

Which PowerCLI version are you using?
Do a

Get-Module -Name VMware.PowerCLI -ListAvailable


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

Reply
0 Kudos
Sunshine_S
Enthusiast
Enthusiast

ModuleType    Version         Name              ExportedCommands
---------- ------- ---- ----------------
Manifest 12.0.0.15947286 VMware.PowerCLI

 

Reply
0 Kudos
LucD
Leadership
Leadership

Can you upgrade to the latest version?


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

Reply
0 Kudos
Sunshine_S
Enthusiast
Enthusiast

I couldn't upgrade in place due to certificate issue so I uninstalled the older version. But it was not getting removed. So I installed the latest version in parallel and then deleted the old module's directory. Now I am running 12.7.0.20091289

Get-Module VMware.PowerCLI -ListAvailable |ft -AutoSize


Directory: C:\Users\XXX\Documents\WindowsPowerShell\Modules


ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 12.7.0.20091289 VMware.PowerCLI


Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 12.7.0.20091289 VMware.PowerCLI

 

I am still getting the same error.

Reply
0 Kudos
LucD
Leadership
Leadership

Then I suggest you open an SR.

If GSS claims PowerCLI is not supported without a Developer Support contract, point them to Online Documentation - PowerCLI 12.3.0 User’s Guide - VMware {code}


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