Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search AD for accounts that expired yesterday

Status
Not open for further replies.

chrisuk11

Technical User
Dec 11, 2011
7
Can anyone provide a script or some links for searching AD for all accounts that expired yesterday?

Once I have these accounts I have a script that will disable / move the account to a specified OU.

Thanks

Edit -

I can get the expiry date and then use the following code to change it to a readable date, just struggling to get the script to check each expiry date and if the expiry date = yesterday then disable the account

Code -

Function Integer8Date(ByVal objDate, ByVal lngBias)
' Function to convert Integer8 (64-bit) value to a date, adjusted for
' local time zone bias.
Dim lngAdjust, lngDate, lngHigh, lngLow
lngAdjust = lngBias
lngHigh = objDate.HighPart
lngLow = objdate.LowPart
' Account for bug in IADslargeInteger property methods.
If (lngLow < 0) Then
lngHigh = lngHigh + 1
End If
If (lngHigh = 0) And (lngLow = 0) Then
lngAdjust = 0
End If
lngDate = #1/1/1601# + (((lngHigh * (2 ^ 32)) _
+ lngLow) / 600000000 - lngAdjust) / 1440
Integer8Date = CDate(lngDate)
End Function
 
Use the DateDiff function:
Code:
If DateDiff("d", DateToCheck, Date()) = 1 then 
	wscript.echo DateToCheck & " was yesterday"
End If
 
thanks for the response.

Will try give it another go this week and see how I get on!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top