VMware Cloud Community
dcoz
Hot Shot
Hot Shot
Jump to solution

report detailing host satp and psp

Hi Guys,

I am trying to create a script that will detail as below.

ESX host           SATP                                        DefaultPSP

testesxhost        VMW_SATP_SYMM                 Fixed

I have got the esxcli commands to connect and query but having issues with the output.

Any help would be appreciated.

$test = @()


foreach($esxcli in Get-EsxCli) {
$details = "" |Select-Object Host, SATP, PSP
   
    $symsatp = $esxcli.nmp.satp.list() | where-Object {$_.name -eq 'VMW_SATP_SYMM'} | select-Object name
    $sympsp = $esxcli.nmp.satp.list() | where-Object {$_.name -eq 'VMW_SATP_SYMM'} | select-Object defaultpsp
   
    $details.satp = $symsatp
    $details.psp = $sympsp
$test += $details
}

$test

Tags (3)
Reply
0 Kudos
1 Solution

Accepted Solutions
vlife201110141
Enthusiast
Enthusiast
Jump to solution

connect-VIServer -server 'xxx' -username 'xxx' -password 'xxx'
$user = 'root'
$pswd = 'xxx'
$vmhost = Get-VMHost
$report = @()
$oldConfig = Get-PowerCLIConfiguration
Set-PowerCLIConfiguration -DefaultVIServerMode "Multiple" -Confirm:$false | Out-Null
foreach($esx in $vmhost){
$esxConnect = Connect-VIServer -Server $esx.name -User $user -Password $pswd
$esxcli = Get-EsxCli -Server $esxconnect
$defaultpsp = ($esxcli.nmp.satp.list() | where{$_.name -eq "VMW_SATP_SYMM"}).defaultpsp
$row = Select-Object -InputObject $esx, $defaultpsp -property @{"Name" = "ESXHost" ; "Expression" = {$esx.name}},
                                                                               @{"Name" = "SATP" ; "Expression" = {"VMW_SATP_SYMM"}},
                                                                               @{"Name" = "DefaultPSP" ; "Expression" = {$defaultpsp}}
$report += $row
                  
Disconnect-VIServer -Server $esx.Name -Confirm:$false
}
$report | Export-Csv "C:\satp_psp.csv" -NoTypeInformation -UseCulture
Set-PowerCLIConfiguration -DefaultVIServerMode $oldConfig.DefaultVIServerMode -Confirm:$false | Out-Null

View solution in original post

Reply
0 Kudos
5 Replies
vlife201110141
Enthusiast
Enthusiast
Jump to solution

connect-VIServer -server 'xxx' -username 'xxx' -password 'xxx'
$user = 'root'
$pswd = 'xxx'
$vmhost = Get-VMHost
$report = @()
$oldConfig = Get-PowerCLIConfiguration
Set-PowerCLIConfiguration -DefaultVIServerMode "Multiple" -Confirm:$false | Out-Null
foreach($esx in $vmhost){
$esxConnect = Connect-VIServer -Server $esx.name -User $user -Password $pswd
$esxcli = Get-EsxCli -Server $esxconnect
$defaultpsp = ($esxcli.nmp.satp.list() | where{$_.name -eq "VMW_SATP_SYMM"}).defaultpsp
$row = Select-Object -InputObject $esx, $defaultpsp -property @{"Name" = "ESXHost" ; "Expression" = {$esx.name}},
                                                                               @{"Name" = "SATP" ; "Expression" = {"VMW_SATP_SYMM"}},
                                                                               @{"Name" = "DefaultPSP" ; "Expression" = {$defaultpsp}}
$report += $row
                  
Disconnect-VIServer -Server $esx.Name -Confirm:$false
}
$report | Export-Csv "C:\satp_psp.csv" -NoTypeInformation -UseCulture
Set-PowerCLIConfiguration -DefaultVIServerMode $oldConfig.DefaultVIServerMode -Confirm:$false | Out-Null

Reply
0 Kudos
dcoz
Hot Shot
Hot Shot
Jump to solution

Thats great thanks for the help.

Dougie

Reply
0 Kudos
dcoz
Hot Shot
Hot Shot
Jump to solution

Hi Guys,

The below script works really well but i want to add the default PSP  for the satp VMW_SATP_ALUA

Tried a couple of things but cant get the script to work. Any help would be appreciated.

$esxCred = Get-Credential -credential 'root'
$vmhost = $WorkingHosts
$ESXHESXCLI = @()
$oldConfig = Get-PowerCLIConfiguration
Set-PowerCLIConfiguration -DefaultVIServerMode "Multiple" -Confirm:$false | Out-Null
foreach($esx in $vmhost){
$esxConnect = Connect-VIServer -Server $esx.name -Credential $esxCred
$esxcli = Get-EsxCli -Server $esxconnect
$defaultpsp = ($esxcli.nmp.satp.list() | where{$_.name -eq "VMW_SATP_SYMM"}).defaultpsp
$defaultnetapppsp = ($esxcli.nmp.satp.list() |Where-Object{$_.name -eq "VMW_SATP_ALUA"}).defaultpsp
$detail = Select-Object -InputObject $esx, $defaultpsp -property @{"Name" = "ESXHost" ; "Expression" = {$esx.name}},
@{"Name" = "SATP" ; "Expression" = {"VMW_SATP_SYMM"}}
@{"Name" = "DefaultPSP" ; "Expression" = {$defaultpsp}}
$ESXHESXCLI += $detail
                 
}
foreach($esx in $vmhost){
Disconnect-VIServer -Server $esx.Name -Confirm:$false
}
$ESXHESXCLI
Reply
0 Kudos
vlife201110141
Enthusiast
Enthusiast
Jump to solution

little bit modification needed ,try this one

connect-VIServer -server 'xxx' -username 'xxx' -password 'xxx'
$user = 'root'
$pswd = 'xxx'
$vmhost = Get-VMHost
$report = @()
$oldConfig = Get-PowerCLIConfiguration
Set-PowerCLIConfiguration -DefaultVIServerMode "Multiple" -Confirm:$false | Out-Null
foreach($esx in $vmhost){
$esxConnect = Connect-VIServer -Server $esx.name -User $user -Password $pswd
$esxcli = Get-EsxCli -Server $esxconnect
$defaultpsp = $esxcli.nmp.satp.list() | where{"VMW_SATP_SYMM", "VMW_SATP_ALUA" -contains $_.name} |
select defaultpsp, name
foreach($item in $defaultpsp){
Add-Member -InputObject $item -MemberType NoteProperty -Name "ESXHost" -Value $esx.name
}
$report += $defaultpsp
Disconnect-VIServer -Server $esx.Name -Confirm:$false
}
$report | Export-Csv c:\report.csv -NoTypeInformation -UseCulture
Set-PowerCLIConfiguration -DefaultVIServerMode $oldConfig.DefaultVIServerMode -Confirm:$false | Out-Null

dcoz
Hot Shot
Hot Shot
Jump to solution

So simple when you see it written 🙂

Thanks that worked a treat.

Dougie

Reply
0 Kudos