PowerShell script exchange
Post Reply
donaldli
Service Provider
Posts: 23
Liked: 4 times
Joined: Mar 17, 2021 3:22 am
Full Name: Donald Li
Contact:

CVcdOrganization and CVcdRef changes in v12.1

Post by donaldli »

We're using following code to retrieve VCD Org information so to further remove restorepoints related to specific Org in specific VDC.

Code: Select all

$vcdOrgItem = Find-VBRvCloudEntity -Organization -Name $OrgName
$vcdHost = $vcdOrgItem.Path.Split('\')[0]
$vcd = Get-VBRServer -Name $vcdHost
$siteRef = ($vcd.Info.Options | Select-Xml -XPath '/root/VcdConnectionOptions/LocalSiteUid').Node.InnerXml
$hostSiteUid = [Veeam.Backup.Model.CVcdRef]::Make($siteRef)
$vcdOrg = New-Object -TypeName Veeam.Backup.Model.CVcdOrganization -ArgumentList $vcdOrgItem.VcdId, $hostSiteUid, $vcdOrgItem.VcdRef, $vcdOrgItem.Name
It's working fine until we recently upgraded to v12.1.
Now it complains TypeNotFound for the CVcdRef.

Code: Select all

$hostSiteUid = [Veeam.Backup.Model.CVcdRef]::Make($siteRef)
Unable to find type [Veeam.Backup.Model.CVcdRef].
At line:1 char:16
+ $hostSiteUid = [Veeam.Backup.Model.CVcdRef]::Make($siteRef)
+                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Veeam.Backup.Model.CVcdRef:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound
Actually, I started to use CVcdRef since v11a because CVcdRef is required while initializing CVcdOrganization.
What's the solution to get over this?
david.domask
Veeam Software
Posts: 1226
Liked: 322 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: CVcdOrganization and CVcdRef changes in v12.1

Post by david.domask »

Hi @donaldli,

Looks like [Veeam.Backup.Model.CVcdRef] got refactored or something as I don't see this under Veeam.Backup.Model anymore.

While I'm sure you probably know, as this is an unsupported method (.NET reflection is not supported), and I'm not confident we will have a fast answer for this. I will try to check, but likely won't be a fast answer.
David Domask | Product Management: Principal Analyst
donaldli
Service Provider
Posts: 23
Liked: 4 times
Joined: Mar 17, 2021 3:22 am
Full Name: Donald Li
Contact:

Re: CVcdOrganization and CVcdRef changes in v12.1

Post by donaldli »

Thanks for your response, David!
This is one of the steps we have to use to remove RestorePoints of tenants who are offboarding from our service.
I opened official support Case "#06037080 — How to remove RestorePoints using PowerShell API remotely" in Apr 2023, and it lasted for 4 months end up with no official support solution.
Back to this question, as [Veeam.Backup.Model.CVcdRef] got refactored, I believe it won't be a required parameter of initializing [Veeam.Backup.Model.CVcdOrganization].
In Veeam v11a, we need [Veeam.Backup.Model.CVcdRef] to initialize a new object of [Veeam.Backup.Model.CVcdOrganization].

Code: Select all

$vcdOrg = New-Object -TypeName Veeam.Backup.Model.CVcdOrganization -ArgumentList $vcdOrgItem.VcdId, $hostSiteUid, $vcdOrgItem.VcdRef, $vcdOrgItem.Name
In Veeam v11, [Veeam.Backup.Model.CVcdRef] is not required.

Code: Select all

$vcdOrg = New-Object -TypeName Veeam.Backup.Model.CVcdOrganization -ArgumentList $vcdOrgItem.VcdId, $vcdOrgItem.VcdRef, $vcdOrgItem.Name
However, I don't know how to New-Object -TypeName Veeam.Backup.Model.CVcdOrganization in v12.1.
If you can show some light on how to initialize [Veeam.Backup.Model.CVcdOrganization], we will not be bothered by [Veeam.Backup.Model.CVcdRef] undefined. Thanks!
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: CVcdOrganization and CVcdRef changes in v12.1

Post by oleg.feoktistov »

Hi Donald,

Checked the code. Looks like in 12.1 CVcdRef class was moved to another namespace. Now it's in Common instead of Model:

Code: Select all

[Veeam.Backup.Common.CVcdRef]::Make(string VcdRef)
It is still required for CVcdOrganization to initialize, but I hope now you can make it work with this updated workaround.

Let me know if it helps.

Best regards,
Oleg
donaldli
Service Provider
Posts: 23
Liked: 4 times
Joined: Mar 17, 2021 3:22 am
Full Name: Donald Li
Contact:

Re: CVcdOrganization and CVcdRef changes in v12.1

Post by donaldli »

Hi Oleg,
Thanks!
I resolved this issue by using $hostSiteUid = $item.VcdRef.GetType()::Make($siteRef), which makes my code work both in Veeam v11 and v12.
Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests