Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to VMC NSX-T & Content Library Module #280

merged 4 commits into from May 7, 2019
Changes from 1 commit
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.


Just for now

Added New-SubscribedContentLibrary function

  • Loading branch information...
lamw committed May 4, 2019
commit 11181a95ecde249a9689b99e2f8563e26d8c5df3
@@ -190,7 +190,7 @@ Function Get-ContentLibraryItemFiles {
$itemIds = $contentLibraryItemService.list($libraryID)
$DatastoreID = $library.storage_backings.datastore_id.Value
$Datastore = get-datastore -id "Datastore-$DatastoreID"

foreach($itemId in $itemIds) {
$itemName = ($contentLibraryItemService.get($itemId)).name
$contentLibraryItemFileSerice = Get-CisService com.vmware.content.library.item.file
@@ -205,7 +205,7 @@ Function Get-ContentLibraryItemFiles {
$fullfilepath = "UNKNOWN"

if(!$LibraryItemName) {
$fileResult = [pscustomobject] @{
Name = $;
@@ -709,4 +709,72 @@ Function New-VMFromVMTX {

Write-Host "`nDeploying new VM $NewVMName from VMTX Template $VMTXName ..."
$results = $vmtxService.deploy($vmtxId,$vmtxDeploySpec)

Function New-SubscribedContentLibrary {
Created by: William Lam
Organization: VMware
Twitter: @lamw
This function creates a new Subscriber Content Library from Subscription URL
.PARAMETER LibraryName
The name of the new vSphere Content Library
.PARAMETER DatastoreName
The name of the vSphere Datastore to store the Content Library
.PARAMETER SubscriptionURL
The URL of the published Content Library
.PARAMETER SubscriptionThumbprint
The SSL Thumbprint for the published Content Library
Specifies whether content is downloaded on-demand (e.g. no immediately)
.PARAMETER AutomaticSync
Specifies whether automatic synchronization with the external content library is enabled
New-SubscribedContentLibrary -LibraryName NestedESXi -DatastoreName vsanDatastore -SubscriptionURL -SubscriptionThumbprint "7a:c4:08:2d:d3:55:56:af:9f:26:43:65:d0:31:99:0b:d2:f3:d8:69" -AutomaticSync
New-SubscribedContentLibrary -LibraryName NestedESXi -DatastoreName vsanDatastore -SubscriptionURL -SubscriptionThumbprint "7a:c4:08:2d:d3:55:56:af:9f:26:43:65:d0:31:99:0b:d2:f3:d8:69" -OnDemand

$datastore = Get-Datastore -Name $DatastoreName

if($datastore) {
$datastoreId = $datastore.ExtensionData.MoRef.Value
$subscribeLibraryService = Get-CisService -Name "com.vmware.content.subscribed_library"

$StorageSpec = [pscustomobject] @{
datastore_id = $datastoreId;
type = "DATASTORE";

$UniqueChangeId = [guid]::NewGuid().tostring()

$createSpec = $
$ = $LibraryName
$createSpec.type = "SUBSCRIBED"
$addResults = $createSpec.storage_backings.Add($StorageSpec)

if($OnDemand) { $OnDemandFlag = $true } else { $OnDemandFlag = $false }
if($AutomaticSync) { $AutomaticSyncFlag = $true } else { $AutomaticSyncFlag = $false }
$createSpec.subscription_info.on_demand = $OnDemandFlag
$createSpec.subscription_info.automatic_sync_enabled = $AutomaticSyncFlag
$createSpec.subscription_info.subscription_url = $SubscriptionURL
$createSpec.subscription_info.authentication_method = "NONE"
$createSpec.subscription_info.ssl_thumbprint = $SubscriptionThumbprint

Write-Host "Creating new Subscribed Content Library called $LibraryName ..."
$library = $subscribeLibraryService.create($UniqueChangeId, $createSpec)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.