none
Powershell script for AD Hostname/OperatingSystem/LastLogonDate and UserLoginName RRS feed

  • Question

  • Hi there, 

    I'm using on AD Server a simple PS script for listing formatted table an output like this

    Name            OperatingSystem                 LastLogonDate
     ----                ---------------                    -------------
    PC-1          Windows 7 Professional          21/05/2019 08:31:52
    PC-2          Windows 7 Professional          12/09/2019 09:21:36
    PC-3          Windows 7 Professional          09/09/2019 08:40:13
    PC-4          Windows 10 Pro                     12/09/2019 07:48:34

    Get-ADComputer -Filter * -Property * | Sort-Object -Property OperatingSystem -Descending|Format-Table Name,OperatingSystem,LastLogonDate -Wrap -Auto

    I'm interested in 1 more information about LastUserNameLogon on that specific Hostname to obtain something like this

    Name            OperatingSystem                 LastLogonDate                LastUserNameLogon
     ----                ---------------                    -------------                     -------------
    PC-1          Windows 7 Professional          21/05/2019 08:31:52        DOMAIN\user1
    PC-2          Windows 7 Professional          12/09/2019 09:21:36        DOMAIN\user2
    PC-3          Windows 7 Professional          09/09/2019 08:40:13        DOMAIN\user3
    PC-4          Windows 10 Pro                     12/09/2019 07:48:34        DOMAIN\user4

    How can I reach this goal? I'm not able to user Powershell scripting on my own , I'm not a developer. Thanks for support.


    • Moved by Bill_Stewart Wednesday, October 23, 2019 5:58 PM This is not "scripts on demand"
    Friday, September 13, 2019 10:01 AM