Hello. Can you please edit your post and use the “preformatted text” button to format your code? It makes it much easier for everyone to read and allows people to copy/paste without having to replace all of the quotes. If you don’t see the button on the toolbar it might be within the gear icon.
a bit yes. It seems like your first code example is compressed into a one-line with ; separating commands instead of line breaks. It’s not very readable.
Regardless I think I see what you’re getting at: You want the local account username, whether or not it’s enabled, and how many days old the password is. I would stick with the Get-LocalUser cmdlet for that and derive the password age from the “PasswordLastSet” property, like this:
But your “PasswordAge” will be a timespan object so a value like this: 173.14:58:38.8450358
means 173 days, 14 hours, 58 minutes, 38 seconds.
If you want just days you might try wrapping that in a subexpression and calling just the TotalDays property.
Thanks my first command came from a tenable.sc audit file check WN19-00-000020. It will go back into the audit file as 1 line. I’m testing customizing this check.
What you gave me worked. Thanks! I was able to get the timespan to round up by type casting [int32] before the expression.