-
-
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
New command for adding a linked server #7392
New command for adding a linked server #7392
Conversation
So this will be part of #6506? |
Hi @andreasjordan, I had not seen that issue, but yes I will update the description of this PR and the other one I just added for removing a linked server so that they both reference 6506. Thanks, |
There is also this one: #6196 |
When I tried the "set" workflow SMO displayed an error message indicating that the linked server has to be dropped and recreated. |
Ok, then maybe you can add the messages to the feature request and close it. |
@potatoqualitee, would it be ok to accept the current scope of this PR as a phase 1? I could come back to the login piece at a later date as a phase 2. I would want to proceed very carefully on that part because of the need for secure credential handling. @andreasjordan, I added the comment to #6196, but I don't have permission to close issues. |
functions/New-DbaLinkedServer.ps1
Outdated
} | ||
|
||
$newLinkedServer.Create() | ||
$newLinkedServer |
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.
Please use Get-DbaLinkedServer to get a nice object with the custom properties for the new linked server:
$instance | Get-DbaLinkedServer -LinkedServer $LinkedServer
functions/New-DbaLinkedServer.ps1
Outdated
$InputObject += Connect-DbaInstance -SqlInstance $instance -SqlCredential $SqlCredential | ||
} | ||
|
||
foreach ($instance in $InputObject) { |
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.
If something is a server SMO with an active connection, so the output of Connect-DbaInstance, we call this $server. And there are definitly server SMOs in $InputObject so I would change this line to
foreach ($server in $SqlInstance) {
That will work, @lancasteradam ! Happy to merge this PR and then you can add later, once @andreasjordan's review has been addressed. |
- Use Get-DbaLinkederver to return the new linked server - Use the $server name convention instead of $instance
Thank you @potatoqualitee and @andreasjordan. I've incorporated the feedback mentioned by @andreasjordan. |
Approved both pull request. |
Fantastic 💯 ! |
Type of Change
Purpose
Basic command to add a new linked server.
Commands to test
See the integration tests.