Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Query for expiration date of AD user accounts within "x" number of days

$
0
0

Hello Everyone,

I'm not big on scripts, but was wondering if there is a vb script I could use to scan my AD domain for accounts that will expire in a set amount of days? (ex. 30, 15, or 7 days) I would then like to export it to a text file. I found the below script in the repo, but it looks to be for a single user. Can it be modified to do what I need?

On Error Resume Next  Set objUser = GetObject _     ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")  
dtmAccountExpiration = objUser.AccountExpirationDate    If Err.Number = -2147467259 Or dtmAccountExpiration = "1/1/1970" Then     WScript.Echo "No account expiration date specified" Else     WScript.Echo "Account expiration date: " & objUser.AccountExpirationDate End If 


G14TS


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>