Loads the sqlps module if the "Invoke-Sqlcmd" cmdlet does not exist. This is the suggested method for loading the module according to MSDN docs. You can download the module installer from here.
Last active
December 19, 2015 14:09
-
-
Save blachniet/5966819 to your computer and use it in GitHub Desktop.
Loads the sqlps module if the "Invoke-Sqlcmd" cmdlet does not exist.
This file contains hidden or 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 Import-Module-SqlServer{ | |
| if (!(Get-Command Invoke-Sqlcmd -ErrorAction SilentlyContinue)){ | |
| Write-Host "Loading SQL Server PowerShell module..." | |
| Import-Module "sqlps" -DisableNameChecking | |
| Write-Host " Done" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment