Hi
I am getting below error when I run the below script, Please help
$report = Get-Cluster |
Get-VMHost -PipelineVariable vmhost |
ForEach-Object {
$esxcli = Get-EsxCli -VMHost $vmhost -V2
Write-Host -ForegroundColor green "Server: $($vmhost.Name)"
$esxcli.storage.nmp.device.list.Invoke() | where { $_.Device -match "^eui\.\w{16}(6c9ce9|6C9CE9)\w{10}"}
$esxcli.storage.nmp.psp.roundrobin.deviceconfig.list.Invoke() | where {$_.Vendor -eq "Nimble"} | select @{N="VMHost";E={$vmhost.Name }}, Description, Name, Vendor, Model, RuleGroup, DefaultPSP, PSPOptions
}
$report
Output
You cannot call a method on a null-valued expression.
At D:\myreports\Multipath_Rules\1_Nimble_List_SATP_rules.ps1:43 char:5
+ $esxcli.storage.nmp.psp.roundrobin.device.list.Invoke()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You have to provide a parameter.
Create the required hash table with CreateArgs()
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Is there perhaps an ESXi node in a cluster that is powered off?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
no, all the esxi are powered on state
Does the previous line $esxcli.storage.nmp.device.list.Invoke() returns results?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
yes, I get the output
Just noticed that $esxcli.storage.nmp.psp.roundrobin.deviceconfig does not have a list method.
There is only a get and set method.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am getting the error, when I use the get
PS D:\> $esxcli = Get-EsxCli -VMHost 10.10.10.144 -V2
PS D:\> $esxcli.storage.nmp.psp.roundrobin.deviceconfig.get()
Method invocation failed because [VMware.VimAutomation.ViCore.Impl.V1.EsxCli.EsxCliElementImpl] does not contain a method named 'get'.
At line:1 char:1
+ $esxcli.storage.nmp.psp.roundrobin.deviceconfig.get()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (get:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
That should be get.Invoke()
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
tried as below, still no luck
PS D:\> $esxcli.storage.nmp.psp.roundrobin.deviceconfig.get.Invoke()
The method 'get' is invoked with '0' parameters, but the expected parameter count is '1'.
At line:1 char:1
+ $esxcli.storage.nmp.psp.roundrobin.deviceconfig.get.Invoke()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], InvalidArgument
+ FullyQualifiedErrorId : VMware.VimAutomation.ViCore.Types.V1.ErrorHandling.InvalidArgument
PS D:\> $esxcli.storage.nmp.psp.roundrobin.deviceconfig.get.Invoke($_.device)
If specified, the arguments parameter must contain a single value of type Hashtable.
At line:1 char:1
+ $esxcli.storage.nmp.psp.roundrobin.deviceconfig.get.Invoke($_.device)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException
You have to provide a parameter.
Create the required hash table with CreateArgs()
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
that worked. thank you