How to check if a domain user account has a blank password (VBScript)
Introduction
This script sample can check if a domain user account has a blank password.
Scenarios
In the domain environment, IT admins usually sets password policies in the domain, but there is another possibility that domain accounts have the potential to login to the domain without a password, user accounts with empty password are more susceptible to attacks.
Script
Step 1: type cmd in the search box on the Start Menu, right-click the cmd.exe icon, and then click Run as administrator. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.
Step 2: Run this VBScript with cscript.exe in the Windows Console (type the name of the script at the command prompt)
When the script finishes running, it shows the brief message as below figure:
Here are some code snippets for your references.
Do Until objRecordSet.EOF
strPath = objRecordSet.Fields("AdsPath").Value
Set strAdUser= GetObject(strPath)
strAdUser.ChangePassword strAdUserPassword, strAdUserPassword
If Err= 0 or Err = -2147023569 Then
intNumber = intNumber + 1
Wscript.Echo "The user account '" & strAdUser.CN & "' has a blank password."
End If
Err.Clear
objRecordSet.MoveNext
Loop
Do Until objRecordSet.EOF strPath = objRecordSet.Fields("AdsPath").Value Set strAdUser= GetObject(strPath) strAdUser.ChangePassword strAdUserPassword, strAdUserPassword If Err= 0 or Err = -2147023569 Then intNumber = intNumber + 1 Wscript.Echo "The user account '" & strAdUser.CN & "' has a blank password." End If Err.Clear objRecordSet.MoveNext Loop
Windows Server 2008 or higher version
Additional Resources
Reference material:
Verify that none of my local user accounts have a blank password
Microsoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.