Script required to disable multiple users on specific date and time

alok singh 1 Reputation point

I Need a powershell script which can disable multiple user on particular specified different different date and time on CSV file. Also i need CSV format for this requirement.

Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
6,190 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Gary Reynolds 9,406 Reputation points

    Hi @alok singh

    It's not possible to schedule users to be disabled at a specified time, however, you could set the user account to expire at a specified time which will prevent the user from logging on.

    Import-Csv .\userList.csv | ForEach {  
        Set-ADAccountExpiration -Identity $_.Username $_.time -WhatIf  

    something like this should do the job.


  2. Gary Reynolds 9,406 Reputation points

    Hi @alok singh

    What cloud identity provider are you using?

    For Azure AD connect you could change to a PTA based configuration, which Ibelieve this will honour the account expiry.


    0 comments No comments