VMware Cloud Community
LordofVxRail
Enthusiast
Enthusiast

Change CIVM Storage Policy ?

Hi All,

 

Can anyone help me with this, I think I'm close but think I'm missing something, possibly with $HREF ?

 

 

### connect
Connect-CIServer -Server $CIServer -User $CIUsername -Password $CIPassword -Org $CIOrg  -WarningAction SilentlyContinue

$HREF = $NULL

$VDCSP = Get-OrgVdc -Name $CIOrgVdc
$VDCSP = $VDCSP.ExtensionData.VdcStorageProfiles
$VDCSP = $VDCSP.VdcStorageProfile

$VMs=Get-CIVM -Name "000_pfsense*" ; foreach ($VM in $VMs)


{

$IP=$VM | Get-CINetworkAdapter | Where-Object {$_.Primary -like "True"} | Select-Object ExternalIPAddress
if ($null -ne $IP.ExternalIPAddress.IPAddressToString) { Write-Host -NoNewLine $IP.ExternalIPAddress.IPAddressToString $VM.vApp.Name ; Write-Output "" }

for ($i=0;$i -le $VDCSP.Length -1;$i++)
{
write-host ” existing storage profile ” $vdcsp[$i].Name -foregroundcolor red 

if ($vdcsp[$i].Name -eq "FTT2")
{
write-host "FTT2"
$HREF = $vdcsp[$i].Href
break
}
}

if ($NULL -eq $HREF)
{
Write-host “Looks like there is no storage profile set on org vdc”
break
}
$newSettings = $VM.extensiondata
$newSettings.storageprofile.name = “$profileName”
$newSettings.storageprofile.Href = “$HREF”
Write-Host “Changing the storage profile for $VM to $profileName”
$newSettings.UpdateServerData()
}	

 

0 Kudos
3 Replies
LordofVxRail
Enthusiast
Enthusiast

I can achieve sam result connecting to viserver, using Set-SpbmEntityConfiguration, but I'd prefer to do this on ciserver

 

 

0 Kudos
Macleud
Enthusiast
Enthusiast

Hello.

Could you describe in more detail. What should your code do?

0 Kudos
Macleud
Enthusiast
Enthusiast

You need to use the ReconfigureVm method.

For example:

$OrgVdc = Search-Cloud -QueryType AdminOrgVdc -name "Vdc_Test"
$VdcStorageProf = Search-Cloud -QueryType AdminOrgVdcStorageProfile -Name "FAST" -filter "Vdc==$($OrgVdc.id)"
$VdcStorageProfView = $VdcStorageProf | Get-CIView
$VM = Get-CIVM -orgvdc "Vdc_Test" -name "Vm_Test-2"
$VmView = $vm | Get-CIView
$VmView.ReconfigureVm($VdcStorageProfView.Href, $null, $null, $null, $null, $null, $null, $null, $null, $null, $null, $null, $null, $null, $null, $VmView.Description, $null, $VmView.name, $null ,$null, $null, $null, $null)
0 Kudos