VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Unable to get nmp satp rule list

Hi,

I am unable to get the nmp satp rule list from ESXi servers as I am getting the below error

Please help

error ::

Get-EsxCli : 04/27/2021 3:38:19 AM Get-EsxCli Value cannot be found for the mandatory parameter VMHost
At D:\purecli\pure_rule_list.ps1:6 char:13
+ $esxcli = Get-EsxCli -VMHost $vmhost -V2
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-EsxCli], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.EsxCli.GetEsxCli

Server:
You cannot call a method on a null-valued expression.
At D:\purecli\pure_rule_list.ps1:8 char:3
+ $esxcli.storage.nmp.satp.rule.list.Invoke() | where{$_.Model -eq "F ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

Get-EsxCli : 04/27/2021 3:38:19 AM Get-EsxCli Value cannot be found for the mandatory parameter VMHost
At D:\purecli\pure_rule_list.ps1:6 char:13
+ $esxcli = Get-EsxCli -VMHost $vmhost -V2
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-EsxCli], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.EsxCli.GetEsxCli

 

#Script

Get-Cluster |
Get-VMHost |
Sort-Object -Property Name |
ForEach-Object {
$esxcli = Get-EsxCli -VMHost $vmhost -V2
Write-Host -foregroundcolor green "Server: $($vmhost.Name)"
$esxcli.storage.nmp.satp.rule.list.Invoke() | where{$_.Model -eq "FlashArray"} | Select @{N="VMHost";E={$vmhost.Name}}, Description, Name, Model, RuleGroup, DefaultPSP, PSPOptions
} | ft -auto
Export-Csv -Path .\test_storage.csv -UseCulture -NoTypeInformation

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You need two separate lines for that.

$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.satp.rule.list.Invoke() | where { $_.Model -eq "FlashArray" } | select @{N = "VMHost"; E = { $vmhost.Name } }, Description, Name, Model, RuleGroup, DefaultPSP, PSPOptions
    }
$report | Format-Table -AutoSize
$report | Export-Csv -Path .\test_storage.csv -UseCulture -NoTypeInformation


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

The variable $vmhost isn't assigned anywhere.
Try like this, it uses the Pipelinevariable.

Get-Cluster |
    Get-VMHost -PipelineVariable vmhost |
    ForEach-Object {
        $esxcli = Get-EsxCli -VMHost $vmhost -V2
        Write-Host -ForegroundColor green "Server: $($vmhost.Name)"
        $esxcli.storage.nmp.satp.rule.list.Invoke() | where { $_.Model -eq "FlashArray" } | select @{N = "VMHost"; E = { $vmhost.Name } }, Description, Name, Model, RuleGroup, DefaultPSP, PSPOptions
    } |
    Export-Csv -Path .\test_storage.csv -UseCulture -NoTypeInformation

 


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

LucD,

That worked but when I tried as below to get the on screen output and csv output at the same time its not working

$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.satp.rule.list.Invoke() | where { $_.Model -eq "FlashArray" } | select @{N = "VMHost"; E = { $vmhost.Name } }, Description, Name, Model, RuleGroup, DefaultPSP, PSPOptions
} | ft -auto
$report | Export-Csv -Path .\test_storage.csv -UseCulture -NoTypeInformation

0 Kudos
LucD
Leadership
Leadership
Jump to solution

You need two separate lines for that.

$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.satp.rule.list.Invoke() | where { $_.Model -eq "FlashArray" } | select @{N = "VMHost"; E = { $vmhost.Name } }, Description, Name, Model, RuleGroup, DefaultPSP, PSPOptions
    }
$report | Format-Table -AutoSize
$report | Export-Csv -Path .\test_storage.csv -UseCulture -NoTypeInformation


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Perfect...Thank you very much 🙂

0 Kudos