09 July, 2020

Powershell: Active Directory - LogOnHours

After looking at what it takes to ~Using Powershell~ manually set the LogOnHours for an AD account. 

I came to the determination that it is WAY easier to use the ADUC interface for this - At least initially...



Manually figuring out, and then plugging in the 21 separate BYTE values into a script, is really a pain in the ass!
Just look at this shit! - And you gotta figure in / convert the times based on UTC... blah, blah, blah!





PS C:\Users\rladuca [07/09/2020 16:54:46]>
(Get-ADUser SalesUser -Properties logonHours).logonHours

0
0
0
0
240
255
0
240
255
0
240
255
0
240
255
0
240
255
0
240
7


Subsequent adjustments to some other accounts LogOnHours, by setting up one of them, then copying that value, is rather easy...





$LogOnHours = (Get-ADUser SalesUser -Properties logonHours).logonHours

Set-ADUser Receptionist -Replace @{logonhours = $LogOnHours}





No comments:

Post a Comment