gd6627
asked on
Modifying a script
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(-($Days Inactive))
Get-ADUser -Filter {LastLogonTimeStamp -lt $time -and enabled -eq $true} -Properties LastLogonTimeStamp |
select-object samaccountname,Name,@{Name =”LAST Logon Time”; Expression={[DateTime]::Fr omFileTime ($_.lastLo gonTimesta mp)}} | export-csv c:\OLD_User.csv -notypeinformation
import-module activedirectory
$domain = “domain.net”
$DaysInactive = 120
$time = (Get-Date).Adddays(-($Days
Get-ADUser -Filter {LastLogonTimeStamp -lt $time -and enabled -eq $true} -Properties LastLogonTimeStamp |
select-object samaccountname,Name,@{Name
How about just using the Mail attribute?
Get-ADUser -Filter {LastLogonTimeStamp -lt $time -and enabled -eq $true} -Properties LastLogonTimeStamp,Mail |
select-object samaccountname,Name,@{Name=”LAST Logon Time”; Expression={[DateTime]::FromFileTime($_.lastLogonTimestamp)}},mail | export-csv c:\OLD_User.csv -notypeinformation
ASKER
When I run the script I get no Output
Which script?
The only change I made to yours was to add the Mail attribute, so if your command was returning items before it still will, unless there's something wrong outside of the script.
The only change I made to yours was to add the Mail attribute, so if your command was returning items before it still will, unless there's something wrong outside of the script.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window