#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++
}