vSphere

Add a VM to Content Library using PowerCLI error |VMware Communities

Hello,

 

I have been trying to upload a VM as a template in the Content Library using Powercli. I am using Stuart Yerdon “Add-TemplateToLibrary” module but its failing with below error.

Source website. How to add a VM to Content Library using PowerCLI – Notes of a scripter

 

vCenter version:  6.5

PowerCli version: 6.5 Release 1, Build 4624819

 

PowerCLI C:> Add-TemplateToLibrary -LibraryName ‘testcontentlib’ -VMname ‘TEST02’ -LibItemName ‘TEST Template’ -Description ‘Uploaded via API calls’

Method invocation failed because [System.Management.Automation.PSCustomObject] does not contain a method named ‘Create’.

At C:ScriptsAdd-TemplateToLibrary.psm1:46 char:1

+ $createOvfTarget = $ContentLibraryOvfService.Help.create.target.Creat …

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (Create:String) [], RuntimeException

    + FullyQualifiedErrorId : MethodNotFound

 

The property ‘library_id’ cannot be found on this object. Verify that the property exists and can be set.

At C:ScriptsAdd-TemplateToLibrary.psm1:47 char:1

+ $createOvfTarget.library_id = $library_ID

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException

    + FullyQualifiedErrorId : PropertyNotFound

 

Method invocation failed because [System.Management.Automation.PSCustomObject] does not contain a method named ‘Create’.

At C:ScriptsAdd-TemplateToLibrary.psm1:49 char:1

+ $createOvfSource = $ContentLibraryOvfService.Help.create.source.Creat …

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (Create:String) [], RuntimeException

    + FullyQualifiedErrorId : MethodNotFound

 

The property ‘type’ cannot be found on this object. Verify that the property exists and can be set.

At C:ScriptsAdd-TemplateToLibrary.psm1:50 char:1

+ $createOvfSource.type = ((Get-VM $VMname).ExtensionData.MoRef).Type

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException

    + FullyQualifiedErrorId : PropertyNotFound

 

The property ‘id’ cannot be found on this object. Verify that the property exists and can be set.

At C:ScriptsAdd-TemplateToLibrary.psm1:51 char:1

+ $createOvfSource.id = ((Get-VM $VMname).ExtensionData.MoRef).Value

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException

    + FullyQualifiedErrorId : PropertyNotFound

 

Method invocation failed because [System.Management.Automation.PSCustomObject] does not contain a method named ‘Create’.

At C:ScriptsAdd-TemplateToLibrary.psm1:53 char:1

+ $createOvfCreateSpec = $ContentLibraryOvfService.help.create.create_s …

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (Create:String) [], RuntimeException

    + FullyQualifiedErrorId : MethodNotFound

 

The property ‘name’ cannot be found on this object. Verify that the property exists and can be set.

At C:ScriptsAdd-TemplateToLibrary.psm1:54 char:1

+ $createOvfCreateSpec.name = $LibItemName

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException

    + FullyQualifiedErrorId : PropertyNotFound

 

The property ‘description’ cannot be found on this object. Verify that the property exists and can be set.

At C:ScriptsAdd-TemplateToLibrary.psm1:55 char:1

+ $createOvfCreateSpec.description = $Description

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException

    + FullyQualifiedErrorId : PropertyNotFound

 

Creating Library Item —  TEST Template

A server error occurred: ‘com.vmware.vapi.std.errors.invalid_argument’: Unable to validate input to method com.vmware.vcenter.ovf.library_item.create (Server error id:

‘vapi.invoke.input.invalid’)Structure ‘operation-input’ is missing a field: create_spec (Server error id: ‘vapi.data.structure.field.missing’). Check

$Error[0].Exception.ServerError for more details.

At C:ScriptsAdd-TemplateToLibrary.psm1:59 char:1

+ $libraryTemplateId = $ContentLibraryOvfService.create($UniqueChangeId …

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : OperationStopped: (:) [], CisServerException

    + FullyQualifiedErrorId : VMware.VimAutomation.Cis.Core.Types.V1.CisServerException

 

Thanks

Sub#


Source link

Related Articles

Leave a Reply

Close