I need to add email address to this script how can I make it where it returns the email in the select -object when it sends it to the csv file
import-module activedirectory
$domain = “domain.net”
$DaysInactive = 120
$time = (Get-Date).Adddays(-($DaysInactive))
Get-ADUser -Filter {LastLogonTimeStamp -lt $time -and enabled -eq $true} -Properties LastLogonTimeStamp |
select-object samaccountname,Name,@{Name=”LAST Logon Time”; Expression={[DateTime]::FromFileTime($_.lastLogonTimestamp)}} | export-csv c:\OLD_User.csv -notypeinformation
Open in new window