Get-ADUser -filter * -properties logonhours to output with days and times?

Paul H 6 Reputation points
2021-09-17T13:33:59.213+00:00

Good Morning,

I am trying to get a powershell script to output usernames and allowed logon times that is useable. I can get an output but the time/date is in system.byte. This is what I am using:

Get-ADUser -filter * -properties LogonHours | export-csv -path (file path)

It spits out a CSV no problem but the logon data is in system.byte. That is my question...What do I need to do to convert it to days and times?

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,435 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Michael Taylor 50,426 Reputation points
    2021-09-17T15:31:22.707+00:00

    It's encoded. Here's a blog article on how to decrypt it with a PS helper script.

    0 comments No comments

  2. Limitless Technology 39,476 Reputation points
    2021-09-17T16:08:29.547+00:00

    Hello @Paul H

    This is an example on how to convert the bytes array to String:

    https://social.technet.microsoft.com/wiki/contents/articles/24594.powershell-convert-the-bytes-array-to-string.aspx

    Hope this is useful,
    Best regards,

    0 comments No comments