Retrieves the allowed logon hours for a user.
Dim arrLogonHoursBytes(20)Dim arrLogonHoursBits(167)arrDayOfWeek = Array _("Sun", "Mon", "Tue", "Wed", _"Thu", "Fri", "Sat")Set objUser = GetObject _("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")objUser.GetInfoEx Array("logonHours"), 0arrLogonHours = objUser.Get("logonHours")For i = 1 To LenB(arrLogonHours)arrLogonHoursBytes(i-1) = AscB(MidB(arrLogonHours, i, 1))NextintCounter = 0intLoopCounter = 0WScript.Echo "Day Byte 1 Byte 2 Byte 3"For Each LogonHourByte In arrLogonHoursBytesarrLogonHourBits = GetLogonHourBits(LogonHourByte)If intCounter = 0 ThenWScript.STDOUT.Write arrDayOfWeek(intLoopCounter) & Space(2)intLoopCounter = intLoopCounter + 1End IfFor Each LogonHourBit In arrLogonHourBitsWScript.STDOUT.Write LogonHourBitintCounter = 1 + intCounterIf intCounter = 8 or intCounter = 16 ThenWScript.STDOUT.Write Space(1)End IfIf intCounter = 24 ThenWScript.echo VbCrintCounter = 0End IfNextNextFunction GetLogonHourBits(x)Dim arrBits(7)For i = 7 to 0 Step -1If x And 2^i ThenarrBits(i) = 1ElsearrBits(i) = 0End IfNextGetLogonHourBits = arrBitsEnd Function
This is a VB Script, this can be used by saving the file in .vbs file