locked
How to write Ad powershell Script that generates list of computers for user list in csv RRS feed

  • Question

  • How to write AD PowerShell Script that generates list of computers for user list in csv

    I need to generate Computers on which users usually logs in for list of users in csv

    • Moved by Bill_Stewart Friday, March 15, 2019 3:09 PM Unanswerable drive-by question
    Thursday, December 13, 2018 7:45 AM

All replies

  • Thursday, December 13, 2018 8:04 AM
  • Active Directory does not track which user logs into which computer.

    One solution is to turn on auditing of all logon/logoff events, then run scripts to parse the event logs for this information. But the event logs get large and discard older information.

    Another solution is to configure logon (and possibly logoff) scripts in a Group Policy that log the user and computer names every time a user logs on (and possibly logs off). The logon script would append a line to a shared log file at each logon. It could be as simple as a batch file, similar to the following.

    @echo off
    echo %date% %time%,%UserName%,%ComputerName% >> \\MyServer\MyShare\LogUsers.log
    

    The resulting comma delimited file can be read into Excel where it can be sorted for analysis. This works best in a small organization where the shared log file is saved locally.

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Thursday, December 13, 2018 10:52 AM
  • One more way to query this is to get the user profiles on the systems given in Csv/txt file.

    like-

    $computers = get-content computerlist.txt

    $adusers = @()

    foreach ( $computer in $computers ) { $adusers += (get-childitem \\computer\C$\users).name }

    then you can fetch the unique ones and remove local administrative,Public.

    #Note: This is just an idea, it is your task to develop the proper script from here.

    Thursday, December 13, 2018 11:50 AM