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

Ask your Windows 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.
Locked
User avatar
cgjackson@yahoo.com
Posts: 7
Meble kuchenne na zamówienie - na wymiar - Wrocław
Joined: Wed Mar 01, 2017 12:54 pm

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: 14342
Joined: Tue May 22, 2007 9:57 am
Contact:

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
Joined: Wed Mar 01, 2017 12:54 pm

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: 14342
Joined: Tue May 22, 2007 9:57 am
Contact:

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
Joined: Wed Mar 01, 2017 12:54 pm

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: 14342
Joined: Tue May 22, 2007 9:57 am
Contact:

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.  
  3. PS C:\scripts> $user.logonhours -join '|'
  4.  
  5. 32|0|0|32|0|0|32|0|0|32|0|0|32|0|0|32|0|0|32|0|0
  6.  
  7. PS C:\scripts>

Locked