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
Code: Select all
#Find-VBRViStoragePolicy
$serverVC = Get-VBRServer -Name "vSphereServer"
Find-VBRViStoragePolicy -Server $serverVC
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
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
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