Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

11
  • 2
    @Maslow I couldn't say for sure, I know that this works fine without disposing of the objects but if you have a single powershell.exe process that will call this multiple times over weeks without closing then it might eventually be an issue but you would have to test that. Commented May 28, 2014 at 14:36
  • 1
    Note that this forces you to write scripts that may be vulnerable to sql injection attacks, if they depend on reading data for the query from a source that relies on user input. Commented Jun 17, 2014 at 21:38
  • 1
    @JoelCoehoorn could you explain a bit more for uninitiated among us? Commented Jan 13, 2017 at 20:00
  • 5
    @AllTradesJack Google Sql Injection. The Invoke-Sql command doesn't have a way to include parameters separate from the command text. This pretty much guarantees you used string concatenation to build the queries, and that's a big no-no. Commented Jan 14, 2017 at 1:36
  • 3
    Works well for me. For anyone wondering, to dispose an object, just add $connection.dispose() etc. I don't know if it makes any difference though Commented Aug 15, 2017 at 11:34