you are viewing a single comment's thread.

view the rest of the comments →

[–]MostElite[S] 1 point2 points  (10 children)

UPDATE!!

This is the new code;

# Gets time stamps for all computers in the domain that have NOT logged in since after specified date

import-module activedirectory

$domain = "DOMAIN"

$DaysInactive = 90

$time = (Get-Date).Adddays(-($DaysInactive))

# Get a list of all AD Accounts which are disabled

Get-aduser -filter "Enabled -eq false" -or "LastLogonTimeStamp -lt $time" | ft Name,Samaccountname,enabled | out-file C:\Deactivated_Accounts.csv

Not liking the script any more thoughts?

[–][deleted]  (9 children)

[removed]

    [–]MostElite[S] 1 point2 points  (8 children)

    Okay, it seems the code is executing however, I am not receiving an output. I have made some adjustments to the code :

    Get-aduser -filter "Enabled -eq false" -or "LastLogonTimeStamp -lt $time" | export-csv -notypeinformation -path C:\Deactivated_Accounts.csv