Automation

 View Only
  • 1.  report detailing host satp and psp

    Posted Nov 01, 2011 11:57 AM

    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



  • 2.  RE: report detailing host satp and psp
    Best Answer

    Posted Nov 01, 2011 01:34 PM

    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



  • 3.  RE: report detailing host satp and psp

    Posted Nov 02, 2011 10:10 AM

    Thats great thanks for the help.

    Dougie



  • 4.  RE: report detailing host satp and psp

    Posted Nov 08, 2011 11:37 AM

    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


  • 5.  RE: report detailing host satp and psp

    Posted Nov 08, 2011 03:51 PM

    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



  • 6.  RE: report detailing host satp and psp

    Posted Nov 08, 2011 07:08 PM

    So simple when you see it written :-)

    Thanks that worked a treat.

    Dougie