Is there a way to schedule account expiration or automating disabling that syncs to Azure AD?

Lewis 21 Reputation points
2022-06-27T16:50:29.433+00:00

I use Powershell to set accounts to expire shortly after a users final shift. The problem is that this attribute is not synced to Azure AD and they are still able to log into teams and O365. Our IT staff is only on-premise during regular working hours, M-F 8-5. It's important that we find a way to prevent a specific users login across the board at a specific time.

Example: Bob's last shift ended Friday at 9PM. Using the typical PowerShell options, we set his account to expire Friday at 9:30PM giving him time to wrap up. Monday morning, we notice that even though he is no longer with our organization, he is still active in teams and trying to carry on direct message conversations with his former colleagues and has forwarded some emails that he received over the weekend. Even though he is no longer able to log directly into a workstation, he can still access Teams and O365. We need to be able to schedule that access to end at the same time that his account expires or shortly after.

Active Directory Federation Services
Active Directory Federation Services
An Active Directory technology that provides single-sign-on functionality by securely sharing digital identity and entitlement rights across security and enterprise boundaries.
1,291 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
23,104 questions
0 comments No comments
{count} votes

Accepted answer
  1. Andy David - MVP 151.8K Reputation points MVP
    2022-06-27T17:01:58.99+00:00

1 additional answer

Sort by: Most helpful
  1. ESP IT Guy 41 Reputation points
    2025-02-04T02:11:22.0333333+00:00

    So dumb, just so dumb. Give us a damn checkbox. I don't want to have to create a registered app to connect a friggin script to the friggin cloud directory which ignores the fact an on prem user is disabled.

    Get bent MS, for the 897th time today. I'm so bored of how many ways you suck.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.