Foreach get-loggedonuser not working in psadt

I have some files that I have to deliver to certain users and I need to handle this with powershell. My issue is that some of these users will be on terminal servers and I’ll have to loop through logged in users to ensure I’m reaching the correct users. My code block works perfectly when running from ISE but when running through PSADT (for mass deploy) it doesn’t do anything at all.

here’s my code block

## <Perform Installation tasks here>

        $LoggedInUser = Get-LoggedOnUser | Select -ExpandProperty 'UserName'

        $AD_Group = "AD Group"

        $TargetURL = "https://url"

        ForEach ($LoggedInUser in $LoggedInUsers) 

            {

                $Path = "$Env:SystemDrive\Users\$LoggedInUser\Desktop\Dashboards\Dashboard.url"

                $Fldr = ($Path | Split-Path)

                If (([ADSISEARCHER]"samaccountname=$(($LoggedInUser))").Findone().Properties.memberof -replace '^CN=([^,]+).+$','$1' -ccontains $AD_Group) 

                    {

                        New-Shortcut -Path $Path `

                            -TargetPath $TargetURL `

                            -Description 'Financial Dashboard'

                    }

            }

Your variable $LoggedInUser on line 1 should be $LoggedInUsers.

Calmly slaps self in forehead.

Thanks for the 2nd set of eyes.