Please see other post Variable "$CurrentLoggedOnUserSession.IsUserSession" is NULL with Intune
and try to use $CurrentLoggedOnUserSession.IsUserSession
If it works for you, you solve YOUR problem and help out for HIS problem
If it fails, you help out for HIS problem and we have a new bug to report (I’ll report it if needed)