Created
July 27, 2012 22:07
-
-
Save naraga/3190703 to your computer and use it in GitHub Desktop.
Executes MSSQL query and pushes output (as PSCustomObject objects) into pipe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function SelectFrom-Mssql([string] $selectQuery) | |
{ | |
. sqlcmd -S "(local)" -d `"mydb`" `-Q "SET NOCOUNT ON $selectQuery" -s "|" -W | | |
ConvertFrom-CSV -Delimiter "|" | | |
select -skip 1 | |
} | |
SelectFrom-Mssql "exec sp_who" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment