-
-
Notifications
You must be signed in to change notification settings - Fork 785
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
Connect-DbaInstance - Make AccessToken
more convenient
#7868
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What a great idea - thanks very much. Have no time to test the code, but changes look very good. I don't see a problem, so go ahead and merge.
@@ -876,6 +877,16 @@ function Connect-DbaInstance { | |||
|
|||
# If we have an AccessToken, we will build a SqlConnection | |||
if ($AccessToken) { | |||
# Check if token was created by New-DbaAzAccessToken or Get-AzAccessToken | |||
Write-Message -Level Debug -Message "AccessToken detected, checking for string or PsObjectIRenewableToken" | |||
if ($AccessToken | Get-Member | Where-Object Name -eq GetAccessToken) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's quite a bit faster! I'll update, thank you 🙇🏼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, in the context of the function they have to pass the object so it will exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More formal method would be to set the type of the parameter you are expecting. If you want them to pass in the object from the output of the other commands, just set the parameter as the type. (cuts out having to check for it)
Now, Connect-DbaInstance will automatically figure out the AccessToken, even if another type of object is returned.