We help IT Professionals succeed at work.
Get Started

powershell problem with expired passwords

549 Views
Last Modified: 2015-09-02
I have a problem with getting the correct password expire date form an active directory:

I need to notify users in timely fashion on expired passwords , so i found a script which worked for other customers:

https://gallery.technet.microsoft.com/Password-Expiry-Email-177c3e27

with this customer i get a few valid values back but not the user which I'm expecting (one who has to change the password in 2 days from now)

with the command net user [username] /domain

i get the values for this user:
Password last set            7/24/2015 11:17:56 AM
Password expires             9/4/2015 11:17:56 AM
Password changeable          7/24/2015 11:17:56 AM

when i run a powershell script:

Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False} –Properties "DisplayName", "msDS-UserPasswordExpiryTimeComputed"|Select-Object -Property "Displayname",@{Name="ExpiryDate";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}}

i get the following output for the same user:
Displayname                             ExpiryDate
-----------                                      ----------
[display name user]                  1/1/1601 1:00:00 AM

so is'clear from the powershell command the paswword will not expire and the script wont sent the email to this user

I'm pretty sure i'm missing something. where comes the difference from in the net user command and the powershell script
and what can i do to solve this ?
Comment
Watch Question
Engineer
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 2 Answers and 4 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE