Public/Get-SCOMRunAsAccountName.ps1

Function Get-SCOMRunAsAccountName{
  <#
      .Synopsis
      Will return the friendly name of a RunAs account.
      .DESCRIPTION
      Often times RunAs account SSIDs will appear in Operations Manager event logs which makes it difficult to determine which account is involved. This will correlate the friendly name with the SSID provided.
      .EXAMPLE
      PS C:\> Get-SCOMRunAsAccountName -SSID '0000F61CD9E515695ED4A018518C053E3CD87251D500000000000000000000000000000000000000'
      .Parameter -SSID
      The SSID as it is presented in the Operations Manager event log; an 80 character string of Hex digits [0-9A-F]
      .NOTES
      Author: Tyson Paul
      Blog: https://monitoringguys.com/
      Original Date: 2013.09.23
      History: I think I originally got most of this from a Technet blog: https://social.technet.microsoft.com/Forums/systemcenter/en-US/0b9bd679-a712-435e-9a27-8b3041cddac8/how-to-find-the-runasaccount-from-the-ssid?forum=operationsmanagergeneral
  #>


  param (
    [Parameter(
        Mandatory=$true,
    HelpMessage="Please enter the SSID")]
    [ValidateNotNull()]
    [ValidateNotNullOrEmpty()]
    [string]$SSID
  )

  Get-SCOMRunAsAccount | Sort-Object Name | ForEach-Object {
    $string = $null;$_.SecureStorageId | ForEach-Object {
      $string = $string + "{0:X2}" -f $_
    }

    $RunAsAccountName = $_.Name
    [string]$RunAsAccountSSID = $string
    If ($SSID -match $RunAsAccountSSID) {
      Write-Host "The Run As Account Name is: $RunAsAccountName"
    }
  }
}