I get a lil twisted… I created this script below:
Import-Module ActiveDirectory
Get-ADUser ‘a87114’ -properties PasswordLastSet, whenCreated | Format-List
$Result = @()
$Users = Get-ADUser a87114 -Properties GivenName,sn,PasswordExpired,whenCreated,PasswordLastSet,PasswordneverExpires
ForEach ($User in $Users)
{ $Result += New-Object PSObject -Property @{
‘Last Name’ = $User.sn
‘First Name’ = $User.GivenName
UserName = $User.SamAccountName
}
}
$Result = $Result | Select ‘Last Name’,‘First Name’,UserName
#Produce a CSV
$Result | Export-Csv “c:\temp\passwordexpirationdate11.csv”
The above display this:
DistinguishedName : CN=A87114,OU=Users,OU=Atlanta-AOC,OU=US,OU=NA,DC=na,DC=ko,DC=com
Enabled : True
GivenName : George
Name : A87114
ObjectClass : user
ObjectGUID : 5275b59f-509f-4418-b615-4a338a99b2d2
PasswordLastSet : 11/26/2013 11:48:01 AM
SamAccountName : A87114
SID : S-1-5-21-1174801143-910442134-930774774-464530
Surname : Jones
UserPrincipalName : a87114@na.ko.com
whenCreated : 8/22/2013 12:03:19 PM
Do you think there’s away to ouput when the password was set and check to see when it was last changed?
I am trying to get a variable like
$date = date
$dataPwdYear = last 4 of $datepwd
$datepwdMonth = left ($datepwd, “/”)
$datePwdDay = mid ($datepwd, “/”, next 2 character)
then
$dateCreate
-
is a minus
If (year - year) = 0 then
If (month-month) = 0 then
If (day-day) = 0 then
If (AM - PM) 2 then
If (hour - hour) <2 then
Else “Error” + output
The goal here is to see if powershell can output when an account password was created and when the account password was changed.
Help