dbatools icon indicating copy to clipboard operation
dbatools copied to clipboard

Copy-SqlLogin - can -Force copy login if login exists and connected

Open olegstrutinskii opened this issue 10 years ago • 8 comments

Please fix issue with killing login connection on destination instance when Copy-SqlLogin used with -Force switch.

olegstrutinskii avatar Oct 26 '16 11:10 olegstrutinskii

Talked to him directly and he'd like a check to see if the user is logged in, and if they are, he'd like a notification before their connection is killed basically saying they're logged in and their connection will be killed.

potatoqualitee avatar Oct 26 '16 11:10 potatoqualitee

he'd like a notification before their connection is killed basically saying they're logged in and their connection will be killed.

So if they are logged in, output "User is logged in, the connection will be killed." and then kill the connection anyways? Or just a warning that says "User is logged in, this would kill the connection."

SirCaptainMitch avatar Oct 26 '16 22:10 SirCaptainMitch

I think if user specified -Force flag, it is better to just kill process and procede forward with all remaining things.

olegstrutinskii avatar Oct 27 '16 08:10 olegstrutinskii

So what your'e saying @Zhunya is that you want the login to be skipped if its logged in? Logins are skipped if Force isn't specified. Not using Force would be a better solution.

potatoqualitee avatar Oct 27 '16 08:10 potatoqualitee

Not using Force for production system better solution, I agree. But if Force specified just kill all login connections add recreate login, thats it, is it clear now? Some times it's very hard for me to explain things in English, sorry.

olegstrutinskii avatar Oct 27 '16 08:10 olegstrutinskii

Ahh yes, very clear now, thank you. That was the original intent of -Force but the kill connection was not immediately before the drop, so the login had time to log back in. We fixed that yesterday in PR #285. Does that cover all of your concerns?

potatoqualitee avatar Oct 27 '16 08:10 potatoqualitee

Yes, thank you!

olegstrutinskii avatar Oct 27 '16 09:10 olegstrutinskii

Excellent, will close this issue. Thanks for following up, @SirCaptainMitch!

potatoqualitee avatar Oct 27 '16 09:10 potatoqualitee