Skip to content

Instantly share code, notes, and snippets.

@Ioan-Popovici
Last active May 18, 2020 13:18
Show Gist options
  • Save Ioan-Popovici/6e4792e4108e58d06313f39abab3dfba to your computer and use it in GitHub Desktop.
Save Ioan-Popovici/6e4792e4108e58d06313f39abab3dfba to your computer and use it in GitHub Desktop.
Gets statically defined health states for a specified bitmask.
'.SYNOPSIS
' Gets statically defined health states.
'.DESCRIPTION
' Gets statically defined health states for a specified bitmask.
'.PARAMETER intBitMask
' Specifies the bitmask to apply.
'.EXAMPLE
' Code.GetHealthStates(Fields!SomeField.Value) (SSRS)
'.EXAMPLE
' GetHealthStates(16) (VB.Net)
'.NOTES
' Created by Ioan Popovici.
'.LINK
' https://SCCM.Zone
'.LINK
' https://SCCM.Zone/Issues
'
'/*##=============================================*/
'/*## SCRIPT BODY */
'/*##=============================================*/
'/* #region FunctionBody */
Function GetHealthStates (ByVal intBitMask As Integer) As String
Dim astrHealthStates() As String = {
"Healthy", "Unmanaged", "Inactive", "Health Evaluation Failed", "Pending Restart", "Update Scan Failed",
"Update Scan Late", "No Maintenance Window", "Distant Maintenance Window", "Expired Maintenance Window"
}
Dim iaHealthStates As Integer
Dim intStep As Integer
Dim strResolvedHealthStates As String = ""
Try
If intBitMask <> 0 Then
For iaHealthStates = 0 To UBound(astrHealthStates)
If intBitMask And intStep Then
If strResolvedHealthStates <> "" Then
strResolvedHealthStates = strResolvedHealthStates + ", "
End If
strResolvedHealthStates = strResolvedHealthStates + astrHealthStates(iaHealthStates)
End If
intStep = 2 ^ iaHealthStates
Next
Else
strResolvedHealthStates = "Healthy"
End If
Catch
strResolvedHealthStates = "Could not resolve health states."
End Try
GetHealthStates = strResolvedHealthStates
End Function
'/* #endregion */
'/*##=============================================*/
'/*## END SCRIPT BODY */
'/*##=============================================*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment