How to have PowerShell to not truncate in the table for logon hours?

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
cgjackson@yahoo.com
Posts: 7
Last visit: Tue Aug 07, 2018 5:16 am

How to have PowerShell to not truncate in the table for logon hours?

Post by cgjackson@yahoo.com »

I have tried several different ways, but it truncates the table:

$User = Get-ADUser -Identity $name -Server $DC1 -Properties SamAccountName,LogonHours

$User.LogonHours



(Get-ADUser -Identity $name -Server $DC1 -Properties SamAccountName,LogonHours).LogonHours



Get-Aduser -Identity $name -Property * -Server $DC1 | Select SamAccountName, logonhours

SamAccountName logonhours

-------------- ----------

spect14 {0, 0, 0, 0...}
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: How to have PowerShell to not truncate in the table for logon hours?

Post by jvierra »

That is because it is an array and not a string.


Get-Aduser -Identity $name -Property * -Server $DC1 | Select -expand logonhours
User avatar
cgjackson@yahoo.com
Posts: 7
Last visit: Tue Aug 07, 2018 5:16 am

Re: How to have PowerShell to not truncate in the table for logon hours?

Post by cgjackson@yahoo.com »

Thanks. That does it. Is there any way to make it not put one at a time.
Is there way to display 0 0 0 0 or whatever the return is thanks again.
Here is the output:
After set MCADDNSTDC03
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: How to have PowerShell to not truncate in the table for logon hours?

Post by jvierra »

Get-Aduser -Identity $name -Property * -Server $DC1 | Select -expand logonhours | %{$_ -join ','}
User avatar
cgjackson@yahoo.com
Posts: 7
Last visit: Tue Aug 07, 2018 5:16 am

Re: How to have PowerShell to not truncate in the table for logon hours?

Post by cgjackson@yahoo.com »

Get-ADUser -Identity $name -Credential $cred -Server $DC8 -Property *| Select -expand logonhours | %{$_ -join ','}
That gives me the same results.
After set MCADDNSTNA01
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: How to have PowerShell to not truncate in the table for logon hours?

Post by jvierra »

  1. PS C:\scripts> $user = get-aduser jsmith -prop logonhours|select logonhours
  2. PS C:\scripts> $user.logonhours -join '|'
  3. 32|0|0|32|0|0|32|0|0|32|0|0|32|0|0|32|0|0|32|0|0
  4. PS C:\scripts>
This topic is 6 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked