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

New command for removing a linked server #7393

Merged
merged 2 commits into from
Jun 18, 2021
Merged

New command for removing a linked server #7393

merged 2 commits into from
Jun 18, 2021

Conversation

lancasteradam
Copy link
Contributor

@lancasteradam lancasteradam commented May 31, 2021

Type of Change

  • Bug fix (non-breaking change, fixes # )
  • New feature (non-breaking change, adds functionality, fixes Commands for managing Linked Server #6506 )
  • Breaking change (effects multiple commands or functionality, fixes # )
  • Ran manual Pester test and has passed (`.\tests\manual.pester.ps1)
  • Adding code coverage to existing functionality
  • Pester test is included
  • If new file reference added for test, has is been added to github.com/sqlcollaborative/appveyor-lab ?
  • Nunit test is included
  • Documentation
  • Build system

Purpose

Basic command for removing a linked server.

Commands to test

See the integration tests and the examples.

@andreasjordan
Copy link
Contributor

Have you tried to use Get-DbaLinkedServer and Remove-DbaLinkedServer in one pipeline? I had issues with that in other Remove- commands and had to move the drop to the end block.
So change the second last test to:

Get-DbaLinkedServer -SqlInstance $instance2 -LinkedServer "LS2_$random" | Remove-DbaLinkedServer -WarningVariable warn

and then test $warn for beeing null or empty.

- Placing the drop() in the end block
@lancasteradam
Copy link
Contributor Author

Thank you @andreasjordan. I have incorporated your feedback.

@potatoqualitee
Copy link
Member

Thank you 🙇🏼 ! These are great. Will add to manifest and release today.

@potatoqualitee potatoqualitee merged commit 268d007 into dataplat:development Jun 18, 2021
@garyhampson
Copy link

garyhampson commented Jun 29, 2021

Hi @lancasteradam - When running this:
Get-DbaLinkedServer -SqlInstance MYSERVER -LinkedServer LINKEDSERVERNAME | Remove-DbaLinkedServer -Confirm:$false
I get the following error:
WARNING: [17:00:32][Remove-DbaLinkedServer] Failure on MYSERVER to remove the linked server LINKEDSERVERNAME | There are still remote logins or linked logins for the server 'LINKEDSERVERNAME'.

This is running 1.0.165 on PS 6.2.4 Core

@lancasteradam
Copy link
Contributor Author

Hi @garyhampson,

Yes, the scope for this first round of linked server commands was more on the simple side of things. Feel free to create an enhancement request to add in the option to remove the logins. In the meantime, you could use https://docs.dbatools.io/Get-DbaLinkedServer to obtain the linked server and then iterate through the logins on that object and call drop() before dropping the linked server itself.

Regards,
Adam

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.

Commands for managing Linked Server
4 participants