Metablaster, I am making the assumption you are trying to figure this out on a non AD joined Windows workstation, such as Windows 10 pro or enterprise. Based on that, I configured a standalone, non-domain joined Windows 10 Enterprise 21h2, fully patched, dot net 4.8 and created two test accounts.
Clean install, NO settings changed, just what comes out of the box. In this state, you can create a local account and NOT set a password and still be able to login to the pc/workstation.
If you create 1 test account without a password, and another with a password then look at them with Get-LocalUser, they look identical.
AccountExpires :
Description : no password
Enabled : True
FullName : test.user01
PasswordChangeableDate :
PasswordExpires : 12/26/2022 8:55:33 PM
UserMayChangePassword : True
PasswordRequired : True
PasswordLastSet : 11/14/2022 8:55:33 PM
LastLogon : 11/15/2022 7:22:30 PM
Name : test.user01
SID : S-1-5-21-497985456-3804842693-4194089287-1002
PrincipalSource : Local
ObjectClass : User
AccountExpires :
Description : Has password
Enabled : True
FullName : test.user02
PasswordChangeableDate : 11/14/2022 8:55:52 PM
PasswordExpires : 12/26/2022 8:55:52 PM
UserMayChangePassword : True
PasswordRequired : True
PasswordLastSet : 11/14/2022 8:55:52 PM
LastLogon :
Name : test.user02
SID : S-1-5-21-497985456-3804842693-4194089287-1003
PrincipalSource : Local
ObjectClass : User
Note that both indicate a password required and password last set. The no password account can login locally. Key word there is locally. Not remote. In back of the brain, a fuzzy memory from my PC support days wants to say there is an explanation about this in the MS docs somewhere.
The following will ensure users can’t have blank passwords.
-
open gpedit.msc, go to computer configuration > windows setting > security settings > account policies > password policy
-
in password policy change the policy “Minimum password length” to anything 1 or greater.
-
on each local account set “user must change password at next logon” to true.
-
make sure no one but a trusted admin has admin on the box so a clever user (never underestimate determined and clever users) can’t reverse these changes.
Now you can be sure everyone has a password. The other option is to join the workstation to an AD domain and users must login with a domain account that is subject to domain password policies that prevent blank passwords.
While doesn’t answer your original question of how to use PowerShell to find local accounts without a password, it some ideas for how you can ensure user do have a password.
The link you shared in your opening post did have one script that seemed to be onto something, I am playing with it and if anything comes of it will share.