How to Get currently logged in user's AD Groups

Product: PowerShell Universal
Version: 2.5.4

I’m trying to take the currently logged in user ( $User ) and gather the user’s ad groups and write them to a local database. I’m trying to make this execute each time a person logs in (only write them to the database if they don’t already exist).

I have the following code in my dashboard .ps1 file, but it the variable is null instead of containing the expected values.

$UserGroups = Get-ADPrincipalGroupMembership

Couple things to note:

  • PSU is running as a windows service
  • Windows authentication is set to false in appsettings.json
  • Login is handled in the authentication.ps1 file
  • Authentication is set to “enabled” on the dashboard “Edit Resource” section in the admin console

User error on this one… I was placing my code to query AD for the user’s groups outside of my udpage. After I placed all the code inside of the UDPage, results were populated as expected.