I am configuring windows 11 clients as part of a project to migrate our infrastructure to intune. As a part of this im running into trouble with a powershell script, that work on our non intune domain clients. I need to check wether the email adress includes the string "@stu.domain" or if its only "@domain". My script is the following:
# Define the path to the executable
$exePath = "C:\Program Files\uniFLOW SmartClient\momsmartclnt.exe"
$currentUser = ([adsi]"LDAP://$(whoami /fqdn)").mail
# Check if the file exists and wether user is a teacher
if (Test-Path $exePath) {
# Run the executable
if($currentUser -notLike "*stu.myDomain*") {
Start-Process -FilePath $exePath
}
} else {
Write-Host "File not found: $exePath"
}
Now when I run this on my uniflow registered client i get the following error:
This translates to: "The FQDN could not be requested, because the current user is not a domain user.
However when I run the whoami command i get the domain/username, but not the full email.
Am I confusing something here or is there a better way to get the full user email from the client?
Thank you in advance for any help / suggestions you may provide.