Get User Running the App

Within an App I am trying to capture the User who is logged in to create an audit log of certain actions that the app does. but All I seem to get is the service account that PSU is running as.

can anyone point me in the right Direction?

Nevermind….. Finally got it working

Can you share the answer?

isn’t that just the $User variable?

And anything else should be in $claimsPrincipal.

    new-UDPage -Content { 
        $columns = @(
            New-UDTableColumn -Property Name
            New-UDTableColumn -Property Value
        )
        $var = @()
        $var += @{name = "User"; value = $User }
        $var += @{name = "Roles"; value = $Roles -join "," }
        $var += @{name = "PSUComputerName"; value = $PSUComputerName }
        $var += @{name = "$($ClaimsPrincipal.identity)"; value = ($ClaimsPrincipal.identity.name) }
        foreach ($item in $ClaimsPrincipal.claims) {
            $var += @{name = "$( ($item.type -split "claims")[-1] )"; value = "$($item.value)" }
        }
        New-UDTable -Data $var -Columns $columns -Title "logged on user account claims"
    } -Title "Home & CLAIMS" -Name "DEV HOME" -Icon @{ type='icon'; icon = 'igloo' }