Skip to content

Instantly share code, notes, and snippets.

@rufflabs
Created December 4, 2015 16:34
Show Gist options
  • Save rufflabs/74426585526d5dce93c6 to your computer and use it in GitHub Desktop.
Save rufflabs/74426585526d5dce93c6 to your computer and use it in GitHub Desktop.
Sets logon hours for AD users to unrestricted.
# Create a HashTable for logonHours, contents is a byte array.
# The code given by AD Admin Center's PowerShell History does not appear to work, but this does.
$logonHours = @{"logonHours" = [byte[]]$hours=@(255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255)}
Set-ADUser $User -Replace $logonHours
@rufflabs
Copy link
Author

rufflabs commented Dec 4, 2015

I found that when setting logon hours to unrestricted, the code given by the AD Administrative Center's PowerShell history function was not working, and gave the error that the property was already present. The above code worked instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment