Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Powershell Script to display Password Expiration

$
0
0

How do I add 90 days to the PasswordLastSet date & extract it to the output?

Below is an excerpt from one of my script & what I attempted to do.

Everything works but the section where I try to add 90 to PasswordLastSet to get Password Expiration Date.

#End Logging Functions
[Int32]$ACntCSV = ""
$Properties = "`"{0}`",`"{1}`",`"{2}`",`"{3}`",`"{4}`",`"{5}`",`"{6}`"" -f "UserID","LastName","FirstName","EmployeeType","LastLogonDate","PasswordLastSet","PasswordExpires"
write-csv "$Properties"

$S = PasswordLastSet
$S.AddDays(90)


[Int32]$II = ""
foreach($Item in $S)
{
$ACntCSV++
$ein = $Item.employeeId
$employee = get-aduser -filter {(employeeType -eq "E") -AND (employeeid -eq $ein)} -Properties surname, givenName | Select surname, givenName
$S[$II].Surname = $employee.Surname
$S[$II].givenName = $employee.givenName
$Global:properties2 = "`"{0}`",`"{1}`",`"{2}`",`"{3}`",`"{4}`",`"{5}`",`"{6}`"" -f $S[$II].name,$employee.Surname,$employee.Givenname,$S[$II].EmployeeType,$S[$II].LastLogonDate,$S[$II].PasswordLastSet,$S[$II].$S
write-csv "$Properties2"
$II++
}


Viewing all articles
Browse latest Browse all 15370

Trending Articles