Hello,
First of all, sorry for my english! I am a beginer in the world of the powershell and i want to learn things. I am stuck for a 5 hours now.
So i want to creat a script on a Windows Server that can tell me who’s password gonna expire in the next 30 days.
When we reach 30 days before the password of the user expire, i want to get notified by an email or SMS ( i already got the material to send SMS).
In order to do this, i started to creat something :
$date = Get-Date $fichier = "C:\Users\username\Documents\fichier.txt" $Listusers = Get-ADUser -Filter * -SearchBase "OU=Test,DC=domain,DC=local" # Creat or update the file $fichier="C:\Users\username\Documents" Set-Location "C:\Users\username\Documents" Remove-Item $fichier -Force # Add the date to the file New-Item -Name "fichier.txt" -ItemType file -Value "$date" # Retrive date of user's password Get-ADUser -Filter * -SearchBase "OU=Test,DC=domain,DC=local" –Properties "DisplayName", "msDS-UserPasswordExpiryTimeComputed" | Select-Object -Property "Displayname",@{Name="ExpiryDate";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}}
When i execute this, no error and everything goes well, but i dont know how to proceed next, everything that i found dont fit what i am searching for.
Hope someone could help me.