I am trying to retrieve a list of all AD users who have accounts expiring in 7 days. Not "within". I found a similar question that was answered on here already, but the script only works for within. My script below works but retrieves accounts that will expire "Within" 7 days. I've tried many different ways all of which do not work.
$List = Search-Adaccount -AccountExpiring -Timespan 07.00:00:00 |
Where-Object {$_.DistinguishedName -like "*OU=test,DC=Domain,DC=com"}
$List | export-csv "c:\temp\expiring_accounts.csv"