Script that disable AD User Account after Login Hours expires

%3CLINGO-SUB%20id%3D%22lingo-sub-2160397%22%20slang%3D%22en-US%22%3EScript%20that%20disable%20AD%20User%20Account%20after%20Login%20Hours%20expires%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2160397%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20guys%2C%3C%2FP%3E%3CP%3EI%20looking%20for%20a%20powershell%20script%20that%20disable%20AD%20User%20Account%20after%20Login%20Hours%20expires!!!%3CBR%20%2F%3EThe%20idea%20is%20configure%20a%20task%20to%20run%20this%20script%20each%205%20minutes.%3C%2FP%3E%3CP%3EAny%20idea%3F%3F%20Is%20it%20possible%20to%20do%20that%3F%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDiogo%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2160397%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2160834%22%20slang%3D%22en-US%22%3ERe%3A%20Script%20that%20disable%20AD%20User%20Account%20after%20Login%20Hours%20expires%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2160834%22%20slang%3D%22en-US%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F976556%22%20target%3D%22_blank%22%3E%40dmello30%3C%2FA%3E%2C%3C%2FP%3E%3CP%3ECan%20you%20please%20elaborate%3F%20What%20are%20you%20trying%20to%20accomplish%3F%3C%2FP%3E%3CP%3EPlease%20describe%20your%20use%20case.%3C%2FP%3E%3CP%3ELogon%20hours%20attribute%20restrict%20the%20time%20that%20user%20is%20allowed%20to%20login%20to%20domain.%3C%2FP%3E%3CP%3EYou%20want%20to%20disable%20user%20after%20logon%20hours%20and%20then%20enable%20it%20back%20again%20during%20the%20logon%20hours%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you.%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi guys,

I looking for a powershell script that disable AD User Account after Login Hours expires!!!
The idea is configure a task to run this script each 5 minutes.

Any idea?? Is it possible to do that?

Thanks

 

Diogo

4 Replies

Hello @dmello30,

Can you please elaborate? What are you trying to accomplish?

Please describe your use case.

Logon hours attribute restrict the time that user is allowed to login to domain.

You want to disable user after logon hours and then enable it back again during the logon hours?

 

Thank you.

@dmello30 

Hi, 

I dont know why you might need to do such a change, as once the logon hour are not applicable, the user wont be able to login.

Anyway Check this script that can take you though 

Hello @AndySvints 

 

Exactly. 

I want disable user after logon hours and then enable it back again during the logon hours.

 

Thanks


Diogo