Hi,
I am trying to create a quick DR-test script with help of Luc's Register-VMX function. However during testing fase I am encountering an issue with the following statement
$ds = Get-Datastore $dsName | Get-View
$dsBrowser = Get-View $ds.Browser
$dc = Get-View $ds.Parent
The error I receive is
The argument cannot be null or empty.
At :line:5 char:20
+ $dc = Get-View <<<< $ds.Parent
I tried this with multiple datastores and enough access rights. I wonder know does vCenter 2.5 u5 support this get-view command ?
thx
Ad
No issue's on a vCenter 4.0.0 build, so I guess I found it.
Hi,
Datastore object is a ManagedEntity since vSphere 4.0. That's why the Parent property is empty on vc 2.5. You can replace this code:
$dc = Get-View $ds.Parent while($dc.MoRef.Type -ne "Datacenter"){ $dc = Get-View $dc.Parent }
with:
$dc = Get-View -ViewType Datacenter -Filter @{datastore=$ds.MoRef.Value}
Regards,
Yasen Kalchev
PowerCLI Dev Team
Ok,
This works however the taskinfo does not receive any data. The script now outputs:
Checking Testds123
Done
I have walked with the debugger throught the script and recognised the point where it goes wrong:
if($folder.file -ne $null){
Looking to the lines above this statement I find:
$task.UpdateViewData("Info.Result")
foreach ($folder in $task.Info.Result){
The debugger variables window shows "Cannot process argument because the value of argument "obj" is null. Change the value of argument "obj" to a non-null value."