Upload Media to vCloud with PowerCLI

June 18, 2013

Table of Contents

This script is a way in which you can upload your media to your vCloud Director Catalog.it is a really nice script for those of us with many ISOs you need to put somewhere safe. Hope it helps:

$isoFolder = “C:MyISOs”

$vdcName = “MyVDC”

$catalogName = “MyCatalog”

# create / delete a cloud media object

Get-ChildItem $isoFolder | %{

$media = New-Object VMware.VimAutomation.Cloud.Views.Media

$media.name = $_.name

$media.ImageType = ‘iso’

$media.size = $_.length

$media.Files = New-Object VMware.VimAutomation.Cloud.Views.FilesList

$media.Files.File = @(new-object VMware.VimAutomation.Cloud.Views.File)

$media.Files.File[0] = new-object VMware.VimAutomation.Cloud.Views.File

$media.Files.file[0].type = ‘iso’

$media.Files.file[0].name = $_.name

$vdc = Get-OrgVdc $vdcName

$vdc.ExtensionData.CreateMedia($media)

$filehref = (Get-Media $media.name | Get-CIView).files.file[0].link[0].href

$webclient = New-Object system.net.webclient

$webclient.Headers.Add(‘x-vcloud-authorization’,$global:DefaultCIServers[0].sessionid)

$webclient.Uploadfile($filehref, ‘PUT’, $_.fullname)

}

#Add non-catalog media to catalog

$mediaList = get-media | where {!$_.catalog}

$catalog = get-catalog $catalogName

foreach ($noCatMedia in $mediaList)

{

 $resEntity = $vdc.extensiondata.resourceEntities.resourceEntity | where {$_.name -eq $noCatMedia.name}

 $catitem = New-Object VMware.VimAutomation.Cloud.Views.CatalogItem

 $catitem.Entity = $resEntity.href

 $catitem.name = $resEntity.name

 $catitem.description = $media.description

 $catalog.extensiondata.createcatalogitem($catitem)

}

Home

 

Share on
Facebook
Twitter
LinkedIn
Pinterest
More posts

Dedicated Servers Quick Guide

What is a Dedicated Servers? Why bother using a dedicated server over a VPS or Shared Hosting?A dedicated server is a server 100% dedicated to your website/project or business needs.

A Look at vCenter 5.5 SSO RC Installation

vCenter single sign on (SSO)  vsphere 5.5  release has several improvements, like the following: Completely re-written from the ground Multi-master architecture Native replication mechanism SSO now has site awareness (think

Release: Veam Backup & Replication 6.5

For those not aware, there has been a new release of the Veam Backup & Replication 6.5. It’s very interesting, the first backup solution for vSphere 5.1 and windows Server

🎉 New Year’s Special🎉
50% OFF for Life!

🔥 DELL Bare-metal Dedicated Server in New York & Amsterdam

💻 Server Highlights:

🔹 Powerful Compute: Dual Intel Xeon Gold (80 Cores, Hyper-Threading)
🔹 Massive Storage: 23TB SSD Flash + 1TB NVMe Boot (HW RAID)
🔹 1TB DDR4 RAM (2666MHz) for Ultimate Multitasking
🔹 10Gbps Redundant Uplinks for Ultra-Fast Connectivity
🔹 10 IPv4 + IPv6 Addresses Included 

💲 Just $699/month – 50% OFF FOR LIFE! (Reg $1399/month)
🚀 Zero Setup Costs | Flexible OS: Ubuntu, Proxmox, ESXi, Windows, etc.

✅ Reserve Risk-Free! 30-Day Money-Back Guarantee
💡 100% Uptime Assurance – Enterprise-Grade Hardware 

🖥 Ideal for Virtualization, Data-Intensive Apps, & High Traffic Sites

Use coupon code at checkout for the discount to apply FBHEO3023EJFB
⚡ Limited Availability – Don’t Miss Out!

Get 90% Discount

First 3 People gets the Bonus!
Don't Miss Out Our Big Sale

Get 0-90% On All
247Rack Services

247Rack

The Sale Is Until The End Of March