Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"/user:" pattern won't detect uses of "/us:" or "u:" #21

Open
techspence opened this issue Jul 29, 2024 · 2 comments
Open

"/user:" pattern won't detect uses of "/us:" or "u:" #21

techspence opened this issue Jul 29, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@techspence
Copy link
Owner

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...

@techspence techspence added the enhancement New feature or request label Jul 29, 2024
@techspence
Copy link
Owner Author

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

techspence added a commit that referenced this issue Nov 10, 2024
@techspence
Copy link
Owner Author

Just pushed efa1088 to dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant