claimsPrincipal and Null problem

Hi there …
Im struggling with ClaimsPrincipal …
Im tring to do a really simple thing, I supposed …
I need to get the Samaccountname logged in (Im using Windows authentication, and its all functionnal)

//This Is OK ==> username is displayed like “DOMAIN\samaccountname”
new-udcard -endpoint {
“You are $($ClaimsPrincipal.identity.name)”
}

//This IS Not OK ==> No user name is displayed
userLoggedIn = ($ClaimsPrincipal.identity.name)
new-udcard -endpoint {
“You are $userLoggedIn”
}

Also trying to get the samaccountname like this but i get nothing.
(($ClaimsPrincipal.identity.name).tostring()).replace(“DOMAIN”,"")

is there an easiest way to get the sam ?

Here is what i do to get the current users SAMAccountName:

$User.Split("\")[1]

Thanks …
Just tried, and tells me ‘can’t do this because its null’ (my french => english translation ^^)
Guess $user is null …

heres is my test code
new-udpage -name “Accueil” -icon home -content {

$thisSamAccountName =  $user.Split("\")[1]

new-udcard -endpoint { 

    "Vous êtes connecté en tant que $thisSamAccountName"

} 

}

using the designer mode, I can see $user is not null.

There is something Im missing ?

Try moving this call into the Endpoint. $User won’t be available outside of an endpoint. Content blocks are static.

new-udcard -endpoint { 
    $thisSamAccountName =  $user.Split("\")[1]
    "Vous êtes connecté en tant que $thisSamAccountName"

} 

Yep it worked ! thank you