Search-ADAccount -AccountExpiring -TimeSpan ([TimeSpan]::FromDays(7)) | Select-Object name*,userpri*,accou*
“FromDays(7)” = this will search accounts that are expiring in 7 days
Select-Object name*,userpri*,accou* = this will print a table with account names, UPN and accountexpirationdate
Pantelis Apostolidis is a Solutions Architect professional at Office Line SA and a recognized Microsoft Azure MVP. For the last 10 years, Pantelis has been involved to major cloud projects in Greece and abroad, helping companies to adopt and deploy cloud technologies, driving business value. He is entitled to a lot of Microsoft Expert Certifications, demonstrating his proven experience in delivering high quality solutions. He is an author, blogger and he is acting as a spokesperson for conferences, workshops and webinars. He is also an active member of several communities as a moderator in azureheads.gr and autoexec.gr. Follow him on Twitter @papostolidis.