Add Invoke-Sqlcmd2 cmdlet

Topics: Developer Forum
Feb 7, 2013 at 7:58 PM
Edited Feb 7, 2013 at 8:00 PM
I would be interested in getting the Invoke-Sqlcmd2 added to PSCX. I use it all of the time to be able to make parametrized queries in SQL. I think it would be helpful to offer people an alternative to Microsoft's Invoke-Sqlcmd that sanitizes inputs.

The original description
Modeled after SQL Server 2008 Invoke-Sqlcmd, but fixes bug in QueryTimeout.
It was later altered by Justin Dearing to support parametrized queries, which is how all SQL queries are supposed to be made. Relevant XKCD

Latest Version of Invoke-Sqlcmd2

I would be happy to help do whatever is necessary to clean it up to meet the PSCX standards, but before I do that I want to know if this cmdlet would be accepted.
Invoke-Sqlcmd2 -ServerInstance "$sqlserver" -Database "$database" `
-Query "INSERT INTO [SomeTable] ([ObjectGUID], [attribute], [attributeValue]) VALUES (@value1, @value2, @value3);" `
-SqlParameters @{ '@value1' = $var1; '@value2' = $var2; '@value3' = $var3 }