ScriptSentry
ScriptSentry copied to clipboard
"/user:" pattern won't detect uses of "/us:" or "u:"
When using net use the following are all valid:
- /user:
- /us:
- /u:
However, only the first /user: is being detected currently. Via quick testing it looks like changing the search pattern to /u.*: may be a good fix...
Using /u[\w]*: would be more robust. Thanks to @guyrleach for the find!
$s1 = "net use * \\acme\f1 /user:acme\itadmin"
$s2 = "net use * \\acme\f1 /use:acme\itadmin"
$s3 = "net use * \\acme\f1 /us:acme\itadmin"
$s4 = "net use * \\acme\f1 /u:acme\itadmin"
$s1 | Select-String -Pattern "/u[\w]*:","-AsPlainText" -AllMatches
$s2 | Select-String -Pattern "/u[\w]*:","-AsPlainText" -AllMatches
$s3 | Select-String -Pattern "/u[\w]*:","-AsPlainText" -AllMatches
$s4 | Select-String -Pattern "/u[\w]*:","-AsPlainText" -AllMatches
---- # OUTPUT # ----
net use * \\acme\f1 /user:acme\itadmin
net use * \\acme\f1 /use:acme\itadmin
net use * \\acme\f1 /us:acme\itadmin
net use * \\acme\f1 /u:acme\itadmin
Just pushed https://github.com/techspence/ScriptSentry/commit/efa10887df63358307197b8100823e7604cab2de to dev