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

Paul H 6 Reputation points

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

    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

    Hello @Paul H

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

    Hope this is useful,
    Best regards,

    0 comments No comments