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

Fixed array logic for Get-SQLServerLoginDefaultPw #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aredspyinthebase
Copy link

@aredspyinthebase aredspyinthebase commented Mar 21, 2025

Bug introduced with original iteration PR to handle multiple credentials: #44

Same effect as #82 version just uses a subexpression to ensure an array of objects is created.

When generating a matching table with Where-Object { $_.instance -eq "$TargetInstance"}, the script assumes it will always return an array of objects, which is not true if there's only one matching instance name, so the iteration and resulting login test will never run.

Further, the iteration over the table incorrectly accesses the username and password fields, so the resulting login check fails because it instead iterates through the string instead of the array.

The change adds a @() subexpression to ensure the $TblResultsTemp is an iteratable collection and moves the element access from $TblResultsTemp.username[$i] to TblResultsTemp[$i].username (same for password field).

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

Successfully merging this pull request may close these issues.

None yet

1 participant