Created
April 21, 2016 19:38
-
-
Save davops/ae183ba614f0a2f7dc52207b9d269ab7 to your computer and use it in GitHub Desktop.
Run SQL queries remotely in PowerShell v2
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
$thisPsSession = New-PSSession "Server1" | |
Invoke-Command -Session $thisPsSession -ScriptBlock { | |
sqlcmd.exe -q "SELECT yourcolumn FROM yourdatabase" | |
} | |
Remove-PSSession $thisPsSession |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment