r/ScriptSwap • • Oct 14 '20

Help with a modification to an existing script.

Hello,

I am wondering if anyone could assist me. I have a need to determine if a specific user account (local user account) has a password set.

I have a script that I found at ServerFault. https://serverfault.com/questions/930582/check-whether-user-account-has-password-set and this script works great. It will scan the local accounts and output if the local accounts do not have a password.

I am wondering if someone could help me modify this script to search for a predefined user account rather than scanning all user accounts.

As an example I am looking for the user account ="pogo246" .

Anyway, if you do have a moment to look I would be very greatful.

Thanks in advance

6 Upvotes

6 comments sorted by

View all comments

1

u/ak_hepcat Oct 14 '20

It's a pretty simple thing to do:

$ test -z "$(grep -qw '^pogo246' /etc/passwd && sudo grep -w '^pogo246' /etc/shadow | cut -f 2 -d: )" && echo "passwd unset"

3

u/raip Oct 14 '20

Pretty sure he's looking for a Windows script and the Serverfault post is in Powershell and uses secedit.

1

u/[deleted] Oct 14 '20

Thank you

1

u/ak_hepcat Oct 14 '20

haha, i didn't even look at the script, my unix-bias is showing.

1

u/[deleted] Oct 14 '20

Hey thanks for sharing. Yes this is for Windows.

I def thank you for the information.