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
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
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
Thats great thanks for the help.
Dougie
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.
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
So simple when you see it written 🙂
Thanks that worked a treat.
Dougie