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...}
How to have PowerShell to not truncate in the table for logon hours?
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.
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.
- 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?
That is because it is an array and not a string.
Get-Aduser -Identity $name -Property * -Server $DC1 | Select -expand logonhours
Get-Aduser -Identity $name -Property * -Server $DC1 | Select -expand logonhours
- 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?
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
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
- 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?
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
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
Re: How to have PowerShell to not truncate in the table for logon hours?
- PS C:\scripts> $user = get-aduser jsmith -prop logonhours|select logonhours
- PS C:\scripts> $user.logonhours -join '|'
- 32|0|0|32|0|0|32|0|0|32|0|0|32|0|0|32|0|0|32|0|0
- PS C:\scripts>