Comments (3)
Overall, this is the behavior of the client library for SQL Server and/or SMO (can't recall which) since a process is tied to the connection, that process ends up being the PowerShell.exe or in your case the PowerShell_ise.exe.
The command is not really intended to close out your current connection but for "gracefully" killing other connections that are active on the instance.
Proposed Solution for the project:
We can/should probably add a warning detection if a user is trying to kill the connection associated to the current process (not sure where those details need to be pulled from but expect it is there).
Proposed Solution for your use-case:
And occasionally when this happens and I go to run my script again (it's setup in a way you can just rerun and it'll start off where it failed) it'll be blocked by the connection that is still open from the first time the script was ran.
I would recommend naming your session on each script run with a unique name that is stored maybe on local file or just have a name that is unique enough where your script as a first step can find "previously failed sessions" and kill those wherever it needs to "restart".
The other option that may work is running that workflow as a job from your script and see if that helps the "failed" runs be removed more gracefully. I can't recall if Start-Job
would still close that thread out or not (been a bit since I have used it).
from dbatools.
You are using connection pooling, which is the default for Connect-DbaInstnce
. So the disconnect only gives the connection back to the pool.
So instead of using Disconnect-DbaInstance
you can use Clear-DbaConnectionPool
to clear the local connection pool. You don't need any parameters. But this effects all connections, not just the one you just opened.
In your case I would use a non pooled connection by adding -NonPooledConnection
to Connect-DbaInstance
. In this case you can close the session with Disconnect-DbaInstance
.
from dbatools.
Will close this now, but can reopen if needed.
from dbatools.
Related Issues (20)
- Backup-DbaDatabase : add a switch that will prevent to always append dbname in the directory backup path and strictly respect the given path variable.
- Get-DbaRegServer - SSMS upgraded from 19.x to 20.1, reading "old" RegisteredServersStore
- Add command to set the instance authentication mode
- Get-DbaHideInstance does not work on a system with named instance HOT 2
- Get-DbaDbBackupHistory - exception on data source length in connection HOT 5
- Issue with creating new directory when Invoke-DbaDbLogShipping. HOT 1
- Find-dbadbunusedindex | write-dbadbtabledata - Incorrect syntax near ')' HOT 7
- Azure Automation Account - issue loading the module HOT 6
- Odd Experience when using Connect-DbaInstance HOT 3
- Test-DbaWindowsLogin add property on account name mismatch HOT 3
- Invoke-DbaQuery's parameter list is oddly formatted. This appears to break the online docs and Get-Help. HOT 9
- Update-DbaInstance can not use secure PS Remoting HOT 1
- dbatools.io / github Slack Invite has expired (again) HOT 1
- Copy-DbaAgentJob fails when trying to copy CDC jobs HOT 3
- New-DbaAgentJobStep -DatabaseUser is not setting the username for the job. HOT 2
- Exception: Couldn't import C:\Program Files\WindowsPowerShell\Modules\dbatools.library\2024.4.12\core\lib\win-sqlclient\Microsoft.Data.SqlClient.dll | Assembly with same name is already loaded
- Warning after run Get-Dbatoolsconfig or Find-DbaInstance on Windows Server 2016 HOT 1
- Restore-DbaDatabase with -Continue when Database has Memory Optimized File Group and/or multiple differential_base_lsn
- Behavior of `Get-DbaDatabase -Database DoesNotExist` HOT 1
- New-DbaAgentSchedule flags an error with a start time before 10000? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dbatools.