1.1.8/Public/get-AllegisSnowUser.ps1

function get-AllegisSnowUser ([string]$snowenv, [pscredential]$snowcred, [string]$uid)
{
    $snowFilter="u_nick_name=$uid^ORemailSTARTSWITH$uid@^ORuser_nameSTARTSWITH$uid@"
    $snowtable='sys_user'    
    $user = $snowcred.username
    $pass = $snowcred.GetNetworkCredential().password
    $method = 'get'
    $uri = "https://$snowEnv.service-now.com/api/now/table/$($snowtable)?sysparm_query=$snowfilter&sysparm_limit=$limit"
    $command="`$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes((""{0}:{1}"" -f '$user', '$pass')))
    `$headers = New-Object ""System.Collections.Generic.Dictionary[[String],[String]]""
    `$headers.Add('Authorization',('Basic {0}' -f `$base64AuthInfo))
    `$headers.Add('Accept','application/json')
    `$response=Invoke-RestMethod -Headers `$headers -Method '$method' -Uri '$uri' -UseBasicParsing -FollowRelLink #-MaximumFollowRelLink 2
    return `$response.result | convertto-json
    "

    $bytes = [System.Text.Encoding]::Unicode.GetBytes($command)
    $encodedCommand = [Convert]::ToBase64String($bytes)

    $results=& 'C:\Program Files\PowerShell\6\pwsh.exe' -encodedcommand $encodedCommand
    $json=$results | convertfrom-json
    return $json
}