PowerShell script exchange
Post Reply
DaKernel
Enthusiast
Posts: 28
Liked: 3 times
Joined: Dec 10, 2019 5:37 pm
Full Name: Larry Heintz
Contact:

Error trying to retrieve all storage policies for datastore

Post by DaKernel »

Hello,

Running into an error while trying to retrieve all storage policies for a datastore. I am trying to retrieve this info so I can try to use powershell to do an instant recovery for a veeam windows agent restore. The Find-VBRViDatastore code below works like it should, it outputs DATASTORE1

Code: Select all

#Find-VBRViDatastore
$serverESXI = Get-VBRServer -Type ESXi -Name "esxiserver1"
$strDatastore = Find-VBRViDatastore -Server $serverESXI -Name "DATASTORE1"
write-host $strDatastore
This code will run and return all the storage policies

Code: Select all

#Find-VBRViStoragePolicy
$serverVC = Get-VBRServer -Name "vSphereServer"
Find-VBRViStoragePolicy -Server $serverVC
Now when I try to run this code, which is a combo of both pieces of code, the error message shows up

Code: Select all

#Find-VBRViDatastore
$serverESXI = Get-VBRServer -Type ESXi -Name "esxiserver1"
$strDatastore = Find-VBRViDatastore -Server $serverESXI -Name "DATASTORE1"

#Find-VBRViStoragePolicy
$serverVC = Get-VBRServer -Name "vSphereServer"
Find-VBRViStoragePolicy -Server $serverVC -Datastore $strDatastore
ERROR MESSAGE

Code: Select all

Find-VBRViStoragePolicy : Server should be host or cluster.
At C:\Scripts\Untitled7.ps1:17 char:1
+ Find-VBRViStoragePolicy -Server $serverVC -Datastore $strDatastore
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Find-VBRViStoragePolicy], Exception
    + FullyQualifiedErrorId : System.Exception,Veeam.Backup.PowerShell.Cmdlets.FindVBRViStoragePolicy

The error "At C:\Scripts\Untitled7.ps1:17 char:1" is at this line Find-VBRViStoragePolicy -Server $serverVC -Datastore $strDatastore

I am alittle confused as to why adding the -Datastore $strDatastore to the line of code is causing the error.

Grateful for any pointers or help

TIA Luke
david.domask
Veeam Software
Posts: 2123
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Error trying to retrieve all storage policies for datastore

Post by david.domask »

Hi @DaKernel it indeed looks weird and I have the same in my lab. Let me try to check a few things (or maybe @@oleg.feoktistov knows already) but no known issues.
David Domask | Product Management: Principal Analyst
DaKernel
Enthusiast
Posts: 28
Liked: 3 times
Joined: Dec 10, 2019 5:37 pm
Full Name: Larry Heintz
Contact:

Re: Error trying to retrieve all storage policies for datastore

Post by DaKernel »

Hi @david.domask and @oleg.feoktistov, any update on this?

TIA Luke
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 669 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Error trying to retrieve all storage policies for datastore

Post by oleg.feoktistov »

Hi Larry,

The point of difference between your separate code snippets and a combo is this row:

Code: Select all

Find-VBRViStoragePolicy -Server $serverVC -Datastore $strDatastore
In the first case you used the cmdlet above without -Datastore parameter and it worked.
So, the issue is with -Server & -Datastore parameters used together. Now, I can see that you also tried to pass vCenter to -Server parameter to query storage policy by a specific datastore. In this case the exception you see is valid since you need to pass esxi host or cluster instead.
Nonetheless, if we use, for instance, an esxi host, the exception is the same, so looks like here comes a bug.
I'll discuss it with QA and update the thread on its status.

Thanks,
Oleg
DaKernel
Enthusiast
Posts: 28
Liked: 3 times
Joined: Dec 10, 2019 5:37 pm
Full Name: Larry Heintz
Contact:

Re: Error trying to retrieve all storage policies for datastore

Post by DaKernel »

Oleg,

Thank you, I was using an esxi host last week in the code and thought that was the issue and looked at the help pages more closely and was using the vCenter server and still had the issue.

TIA Luke
david.domask
Veeam Software
Posts: 2123
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Error trying to retrieve all storage policies for datastore

Post by david.domask »

DaKernel wrote: May 26, 2022 3:59 pm Hi david.domask and oleg.feoktistov, any update on this?

TIA Luke
Still checking internally and discussing. I will update once we have an answer.
David Domask | Product Management: Principal Analyst
DaKernel
Enthusiast
Posts: 28
Liked: 3 times
Joined: Dec 10, 2019 5:37 pm
Full Name: Larry Heintz
Contact:

Re: Error trying to retrieve all storage policies for datastore

Post by DaKernel »

Thank you for staying on top of this David!
david.domask
Veeam Software
Posts: 2123
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Error trying to retrieve all storage policies for datastore

Post by david.domask »

Updating the thread, @DaKernel, thanks for reporting this. Our RND confirms there is an issue due to an incorrect check being done on VC hosts passed to Find-VBRViStorageEntity (Find-VBRViDatastore is impacted also).

The issue is set to be resolved in a future release so it will be handled :)
David Domask | Product Management: Principal Analyst
DaKernel
Enthusiast
Posts: 28
Liked: 3 times
Joined: Dec 10, 2019 5:37 pm
Full Name: Larry Heintz
Contact:

Re: Error trying to retrieve all storage policies for datastore

Post by DaKernel »

Thank you, David.

Is there a workaround at all?
david.domask
Veeam Software
Posts: 2123
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Error trying to retrieve all storage policies for datastore

Post by david.domask »

You're welcome!

For Find-VBRViDatastore, you can pass an ESXi host to get the datastores; you can pull the hosts with the GetChilds() method on the vCenter Object.

For Storage policies, regrettably right now there is no workaround. I would advise that until we get a fix in a future release, try passing some of the name outputs from Veeam to PowerCLI (for example, Get-SpbmEntityConfiguration)
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests