Mar 29 2024 07:00 AM
Hi, we have Entra ID p2 licenses, however cannot select the option "Inactive Users (On Tenant Level) only" in the access review. Wherefore i cannot specify the timeframe after which guests account are deemed inactive.
To circumvent this i wrote a script, which connects to Microsoft Graph with a registered app. This to list and remove guest accounts within their proper time frames. I wanted the run the script with an automation account (PowerShell Runbook), however the script does not recognize the Microsoft.graph commands, even though both modules have been installed (Microsoft.graph.users and Microsoft.Graph.Beta.users). Also the 2 modules are explicitly imported at the start of the PowerShell script.
The script works when i run it from a computer, so the script is valid. But also onprem i bump into a strange issue. I created a scheduled task to run the script from an OnPrem Server, when i run the scheduled task under my account, then the script works as expected, however when i run the task under a single managed service account, then the script runs but fail to retrieve any guests users from the tenant. Script logging shows that the script successfully connects to the tenant as the registered application, but does not retrieve any guest accounts. This cannot be related to permission as the script always runs on the Graph API permissions assigned to the registered app.
Mar 29 2024 08:14 AM
Mar 30 2024 12:51 PM
SolutionMar 30 2024 12:51 PM
Solution