question

Arni-3472 avatar image
0 Votes"
Arni-3472 asked DaisyZhou-MSFT commented

List All Users Last Logon on specific OU (child OU) Active Directory

Hi,

I tried this PowerShell script but this is only good for the parent ou. I am looking for the Child OU. How can I modify this PowerShell below or if you could assist in providing a new script, would be great.

Get-ADUser -filter * -SearchBase 'ou=Offices,DC=contoso,DC=com' -Properties LastLogonTimeStamp | Select sAmAccountName,@{label="LastLogonTimeStamp";Expression={if($.LastLogonTimeStamp){[datetime]::FromFileTime([Int64]$.LastLogonTimeStamp)} Else {"Never"}}}

Thank you!

windows-active-directory
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @Arni-3472,
How are things going on your end? Please keep me posted on this issue.
If you have any further questions or concerns about this question, please let us know.
I appreciate your time and efforts.

Best Regards,
Daisy Zhou

0 Votes 0 ·

1 Answer

DaisyZhou-MSFT avatar image
0 Votes"
DaisyZhou-MSFT answered

Hello @Arni-3472,

Thank you for posting here.

Based on the description, I run your command in my lab, it work fine.

For example:
We can specify the parent OU (it will list users in parent OU and in all child OU within this parent OU).
82207-last1.png

We can We can specify the child OU(it will list users in specific child OU).

82208-last3.png

I am sorry, I can not understand what your actual request.

If anything I misundestood, please feel free to let us know.



Best Regards,
Daisy Zhou



last1.png (69.5 KiB)
last3.png (26.2 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.