$User = Get-MGUser | Where-Object UserPrincipalName -eq $UserPrincipalName
This works perfectly - I connect to Microsoft Graph and can run this. But when I run this in my script - it returns a null value?
I connect to microsoft graph and UserPrincipalName is a valid variable with a valid UPN.
What gives?