Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Import-Module VMware.VimAutomation.Core
- Import-Module VMware.PowerCLI | Out-Null
- Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false | Out-Null
- Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $true -Confirm:$false | Out-Null
- Function ESXiConnect
- {
- #### connect to ESXi host
- $ESXiUser = ###ESXiUser
- $ESXiHost = ###ESXiHost
- $ESXiPassword = ###ESXiPassword
- try{
- Connect-VIServer $ESXiHost -User $ESXiUser -Password $ESXiPassword -WarningAction SilentlyContinue -ErrorAction Stop | Out-Null
- }
- catch{
- Write-Host "Cant connect to ESXi Server" -ForegroundColor Red
- }
- }
- Function getPDState{
- $esxcli = Get-EsxCli -V2
- $sArg = @{
- command = "./storcli show J"
- workdir = "/opt/lsi/storcli"
- }
- $concount = ($esxcli.shell.cmd.Invoke($sArg) | ConvertFrom-Json).Controllers.'Response Data'.'Number of Controllers'
- Write-Output "EID/Slt|DID|State|DG|Size|Intf|Med|SED|PI|SeSz|Model|Sp|Type"
- for($controller=0; $controller -le ($concount-1); $controller++)
- {
- $esxcli = Get-EsxCli -V2
- $sArg = @{
- command = "./storcli /c$controller show J"
- workdir = "/opt/lsi/storcli"
- }
- $Output = $esxcli.shell.cmd.Invoke($sArg) | ConvertFrom-Json
- $PDLIST = $Output.Controllers.'Response Data'.'PD LIST'
- foreach ($PD in $PDLIST)
- {
- $OutObject = New-Object System.Object
- $OutObject | Add-Member -type NoteProperty -name EIDSlt -value $PD.'EID:Slt'
- $OutObject | Add-Member -type NoteProperty -name DID -value $PD.DID
- $OutObject | Add-Member -type NoteProperty -name State -value $PD.State
- $OutObject | Add-Member -type NoteProperty -name DG -value $PD.DG
- $OutObject | Add-Member -type NoteProperty -name Size -value $PD.Size
- $OutObject | Add-Member -type NoteProperty -name Intf -value $PD.Intf
- $OutObject | Add-Member -type NoteProperty -name Med -value $PD.Med
- $OutObject | Add-Member -type NoteProperty -name SED -value $PD.SED
- $OutObject | Add-Member -type NoteProperty -name PI -value $PD.PI
- $OutObject | Add-Member -type NoteProperty -name SeSz -value $PD.SeSz
- $OutObject | Add-Member -type NoteProperty -name Model -value $PD.Model
- $OutObject | Add-Member -type NoteProperty -name Sp -value $PD.Sp
- $OutObject | Add-Member -type NoteProperty -name Type -value $PD.Type
- #output in netXMS table view
- $OutObject.EIDSlt + '|' + $OutObject.DID + '|' + $OutObject.State + '|' + `
- $OutObject.DG + '|' + $OutObject.Size + '|' + $OutObject.Intf + '|' + `
- $OutObject.Med + '|' + $OutObject.SED + '|' + $OutObject.PI + '|' + `
- $OutObject.SeSz + '|' + $OutObject.Model + '|' + $OutObject.Sp + '|' + $OutObject.Type
- }
- }
- }
- Function getVDState{
- $esxcli = Get-EsxCli -V2
- $sArg = @{
- command = "./storcli show J"
- workdir = "/opt/lsi/storcli"
- }
- $concount = ($esxcli.shell.cmd.Invoke($sArg) | ConvertFrom-Json).Controllers.'Response Data'.'Number of Controllers'
- Write-Output "DG/VD|Name|TYPE|State|Access|Consist|Cache|Cac|sCC|Size"
- for($controller=0; $controller -le ($concount-1); $controller++)
- {
- $esxcli = Get-EsxCli -V2
- $sArg = @{
- command = "./storcli /c$controller show J"
- workdir = "/opt/lsi/storcli"
- }
- $Output = $esxcli.shell.cmd.Invoke($sArg) | ConvertFrom-Json
- $VDLIST = $Output.Controllers.'Response Data'.'VD LIST'
- foreach ($VD in $VDLIST)
- {
- $OutObject = New-Object System.Object
- $OutObject | Add-Member -type NoteProperty -name DGVD -value $VD.'DG/VD'
- $OutObject | Add-Member -type NoteProperty -name Type -value $VD.Type
- $OutObject | Add-Member -type NoteProperty -name State -value $VD.State
- $OutObject | Add-Member -type NoteProperty -name Access -value $VD.Access
- $OutObject | Add-Member -type NoteProperty -name Consist -value $VD.Consist
- $OutObject | Add-Member -type NoteProperty -name Cache -value $VD.Cache
- $OutObject | Add-Member -type NoteProperty -name Cac -value $VD.Cac
- $OutObject | Add-Member -type NoteProperty -name sCC -value $VD.sCC
- $OutObject | Add-Member -type NoteProperty -name Size -value $VD.Size
- $OutObject | Add-Member -type NoteProperty -name Name -value $VD.Name
- #output in netXMS table view
- $OutObject.DGVD + '|' + $OutObject.Name + '|' + $OutObject.Type + '|' + `
- $OutObject.State + '|' + $OutObject.Access + '|' + $OutObject.Consist + '|' + `
- $OutObject.Cache + '|' + $OutObject.Cac + '|' + $OutObject.sCC + '|' + $OutObject.Size
- }
- }
- }
- Function GetControllersState{
- $esxcli = Get-EsxCli -V2
- $sArg = @{
- command = "./storcli show J"
- workdir = "/opt/lsi/storcli"
- }
- $concount = ($esxcli.shell.cmd.Invoke($sArg) | ConvertFrom-Json).Controllers.'Response Data'.'Number of Controllers'
- Write-Output "Model|Controller|Serial Number|State|Memory Correctable Errors|Memory Uncorrectable Errors"
- for($controllers=0; $controllers -le ($concount-1); $controllers++)
- {
- $esxcli = Get-EsxCli -V2
- $sArg = @{
- command = "./storcli /c$controllers show all J"
- workdir = "/opt/lsi/storcli"
- }
- $Output = $esxcli.shell.cmd.Invoke($sArg) | ConvertFrom-Json
- $CONTROLLERLIST = $Output.Controllers.'Response Data'
- foreach ($controller in $CONTROLLERLIST)
- {
- $OutObject = New-Object System.Object
- $OutObject | Add-Member -type NoteProperty -name Model -value $controller.Basics.Model
- $OutObject | Add-Member -type NoteProperty -name Controller -value $controller.Basics.Controller
- $OutObject | Add-Member -type NoteProperty -name SerialNumber -value $controller.Basics.'Serial Number'
- $OutObject | Add-Member -type NoteProperty -name ControllerStatus -value $controller.Status.'Controller Status'
- $OutObject | Add-Member -type NoteProperty -name CorrectableErrors -value $controller.Status.'Memory Correctable Errors'
- $OutObject | Add-Member -type NoteProperty -name UncorrectableErrors -value $controller.Status.'Memory Uncorrectable Errors'
- #output in netXMS table view
- $OutObject.Model + '|' + $OutObject.Controller + '|' + $OutObject.SerialNumber + '|' + `
- $OutObject.ControllerStatus + '|' + $OutObject.CorrectableErrors + '|' + $OutObject.UncorrectableErrors
- }
- }
- }
- ESXiConnect
- GetControllersState
- getVDState
- getPDState
- Disconnect-VIServer -Confirm:$false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement