New-ContentLibraryItem Command | Vmware PowerCLI Reference

New-ContentLibraryItem

This cmdlet creates a new content library item in the specified content library. If the Files parameter is specified, you can add the specified files to the newly created content library item.

Syntax

New-ContentLibraryItem
-ContentLibrary < LocalContentLibrary >
-Name < String >
[-DisableOvfCertificateChecks ]
[-Files < String[] > ]
[-ItemType < String > ]
[-Notes < String > ]
[-ProgressAction < ActionPreference > ]
[-Server < VIServer[] > ]
[CommonParameters]

Parameters

Required Parameter Name Type Position Features Description
required
ContentLibrary LocalContentLibrary named
  • pipeline
  • wildcards
Specifies a local content library that hosts the content library item.
required
Name String named
Specifies the name of the library item. The library item names cannot be undefined or an empty string. Names do not have to be unique.
optional DisableOvfCertificateChecks SwitchParameter named
Specifies to skip all OVA/OVF certificate checks during the upload to the content library item.
optional Files String[] named
Specifies the paths to local or remote files that you want to add to the newly created content library item.
optional ItemType String named
Specifies the type of the library item.
optional Notes String named
Specifies a human-readable description for the content library item that you want to create.
optional ProgressAction ActionPreference named
optional Server VIServer[] named
Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of the Connect-VIServer cmdlet.

Output

VMware.VimAutomation.ViCore.Types.V1.ContentLibrary.ContentLibraryItem

Examples

Example 1

$files = Get-ChildItem -File$localContentLibrary = Get-ContentLibrary -name 'Local content library' -LocalNew-ContentLibraryItem -ContentLibrary $localContentLibrary -name 'New item' -Files $files

Creates a content library item named 'New item' in the 'Local content library' library, containing all the files from the C: directory.

Example 2

$files = Get-ChildItem -Name '*.ps1' -File$localContentLibrary = Get-ContentLibrary -Name 'Local content library' -LocalNew-ContentLibraryItem -ContentLibrary $localContentLibrary -Name 'New item' -ItemType 'script' -Files $files

Creates a content library item named 'New item' in the 'Local content library' library, containing all PowerShell script files from the C: directory. The type of the content library item is 'script'.

Example 3

$datastore = Get-Datastore -Name 'Datastore'$localContentLibrary = Get-ContentLibrary -Name 'Local content library' -LocalNew-ContentLibraryItem -ContentLibrary $localContentLibrary -Name 'New item' -Uri ($datastore.ExtensionData.Info.Url + 'ISOs/Photon-minimal-3.0.iso') -FileName 'Photon-minimal-3.0.iso'

Creates a content library item named 'New item' in the 'Local content library' library, containing a 'Photon-minimal-3.0.iso' file from the 'Datastore' datastore.

Example 4

$vm = Get-VM -Name 'MyVM'$resourcePool = Get-ResourcePool -Name 'MyResourcePool'$localContentLibrary = Get-ContentLibrary -Name 'Local content library' -LocalNew-ContentLibraryItem -ContentLibrary $localContentLibrary -Name 'VM template library item' -VM $vm -VMTemplate -Location $resourcePool

Creates a virtual machine template content library item named 'VM template library item' in the 'Local content library' library from the 'MyVM' virtual machine. The associated virtual machine template is placed in the 'MyResourcePool' resource pool.

Example 5

$vm = Get-VM -Name 'MyVM'$vmhost = Get-VMHost -Name 'MyVMHost'$vmFolder = Get-Folder -Name 'MyVMFolder'$localContentLibrary = Get-ContentLibrary -Name 'Local content library' -LocalNew-ContentLibraryItem -ContentLibrary $localContentLibrary -Name 'VM template library item' -VM $vm -VMTemplate -Location $vmhost -InventoryLocation $vmFolder

Creates a virtual machine template content library item named 'VM template library item' in the 'Local content library' library from the 'MyVM' virtual machine. The associated virtual machine template is placed on the 'MyVMHost' host and in the 'MyVMFolder' virtual machine folder.

Example 6

$template = Get-Template -Name 'MyTemplate'$localContentLibrary = Get-ContentLibrary -Name 'Local content library' -LocalNew-ContentLibraryItem -ContentLibrary $localContentLibrary -Name 'OVF template library item' -Template $template

Creates an OVF template content library item named 'OVF template library item' in the 'Local content library' library from the 'MyTemplate' virtual machine template.

Example 7

$ovaFile = Get-ChildItem -Name 'photon.ova'$localContentLibrary = Get-ContentLibrary -Name 'Local content library' -LocalNew-ContentLibraryItem -ContentLibrary $localContentLibrary -Name 'New item' -Files $ovaFile -DisableOvfCertificateChecks

Creates a content library item named 'New item' in the 'Local content library' library, containing a 'photon.ova' OVA file, and deactivate OVA/OVF certificate checks during the upload.

Related Commands

ContentLibrary

This cmdlet creates a new local or subscribed content library.

Creates a new local or subscribed content library that uses Datastore1 as a repository for its items.

This cmdlet removes the specified content libraries.

This cmdlet modifies content library's properties.

ContentLibraryItem

This cmdlet copies content library items to a local content library.

This cmdlet exports content library item's files to the local machine.

This cmdlet retrieves catalog items from the content library.

This cmdlet creates a new content library item in the specified content library.

This cmdlet removes the specified content library items.

This cmdlet modifies content library item's properties.