Quantcast
Channel: VMware Communities : Document List - vSphere PowerCLI
Viewing all articles
Browse latest Browse all 379

Change Storage Profile on Medias after vCloud Director Upgrade to 5.1

$
0
0

#Here is a script example to change the *any Profile to the correct one, after an Upgrade to vCloud Director 5.1

$medias = get-media

$i=1

$total = $medias.count

foreach($media in $medias){

$storageprofile = $media.OrgVdc.ExtensionData.VdcStorageProfiles.VdcStorageProfile | Where-Object {$_.name -ne "*"}

$storageprofilehref = $storageprofile.href.replace("/admin","")

$storageprofilename = $storageprofile.name

if($media.ExtensionData.VdcStorageProfile.name -eq $storageprofilename){

  Write-Host "Storageprofile already changed for Media: $($media.name) to Storageprofile:$($storageprofile.name), $i/$total"

} else {

  try {

   Write-Host "Change Storage Profile for Media: $($media.name) to Storageprofile:$($storageprofile.name), $i/$total"

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

   $TempMedia = $media

   $TempMedia.ExtensionData.VdcStorageProfile.Href = $storageProfileHref

   $TempMedia.ExtensionData.VdcStorageProfile.Name = $storageprofilename

   $TempMedia.ExtensionData.updateServerData()

   Write-Host "Successfully change Storage Profile for Media: $($media.name) to Storageprofile:$($storageprofile.name)"

  } catch {

   Write-Warning "Error changing Storage Profile for Media: $($media.name) to Storageprofile:$($storageprofile.name) for OvDC: $($media.orgvdc.name)"

  }

}

$i++

}


Viewing all articles
Browse latest Browse all 379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>