Public/Get-PanelHardwareStatus.ps1
|
<#
.SYNOPSIS Gets the panel hardware status. .DESCRIPTION Gets the panel hardware status for all panels or the hardware status for a single panel if an panel id is specified. If the result returns null, try the parameter "-Verbose" to get more details. .EXAMPLE Get-PanelHardwareStatus .LINK https://github.com/erwindevreugd/PSDataConduIT .EXTERNALHELP PSDataConduIT-help.xml #> function Get-PanelHardwareStatus { [CmdletBinding()] param ( [Parameter( Position = 0, Mandatory = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = 'The name of the server where the DataConduIT service is running or localhost.')] [string] $Server = $Script:Server, [Parameter( Position = 1, Mandatory = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = 'The credentials used to authenticate the user to the DataConduIT service.')] [PSCredential] $Credential = $Script:Credential, [Parameter( Mandatory = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = 'Specifies the id of the panel for which to get the hardware status.')] [int] $PanelID ) process { $parameters = @{ Server = $Server; } if ($Credential -ne $null) { $parameters.Add("Credential", $Credential) } if (($panels = Get-Panel @parameters -PanelID $PanelID) -eq $null) { return } foreach ($panel in $panels) { try { Write-Verbose -Message "Updating hardware status for panel '$($panel.Name)'" $panel.UpdateHardwareStatus.Invoke() | Out-Null $status = $panel.GetHardwareStatus.Invoke().Status $panelStatus = [Enum]::GetValues([PanelStatus]) | Where-Object { $_ -band [int]$status } Write-Verbose -Message ("Panel '$($panel.Name)' status is '$($panelStatus)'") } catch { Write-Warning -Message ("Failed to retrieve hardware status for panel '$($panel.Name)'") $panelStatus = "Failed" } New-Object PSObject -Property @{ Name = $panel.Name; Status = $panelStatus; } | Add-ObjectType -TypeName "DataConduIT.LnlPanelHardwareStatus" } } } |