Public/Get-CurrentUserSid.ps1

function Get-CurrentUserSid
{
    <#
        .DESCRIPTION
            Get the SID for a given user
    
        .EXAMPLE
            $UserSid = Get-CurrentUserSid -Username $User
    
        .NOTES
            Created by: Jon Anderson
            Modified: 2023-07-03
    #>

    [CmdletBinding()]
    param(
        [parameter(Mandatory = $true)][ValidateNotNullOrEmpty()]
        [Object]$Username
    )

    $User = New-Object System.Security.Principal.NTAccount($Username.Username)
    $Sid = $User.Translate([System.Security.Principal.SecurityIdentifier])
    Write-Output "Converted $Username to SID: $($Sid.Value)"
    return $Sid.Value
}