Last active
October 17, 2020 02:43
-
-
Save phillipsj/aee9a2484ecd2bc44bfff1bcb49bffb2 to your computer and use it in GitHub Desktop.
Really simple test for a database.
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 Invoke-DatabaseTest | |
{ | |
param( | |
[parameter(mandatory = $true)] | |
[ValidateNotNullOrEmpty()] | |
[String] $DatabasePort, | |
[parameter(mandatory = $true)] | |
[ValidateNotNullOrEmpty()] | |
[String] $DatabaseName, | |
) | |
$Result = Invoke-Sqlcmd -Query "SELECT COUNT(*) FROM [Production].[Product]" -ConnectionString "Server=localhost,$($DatabasePort);Database=$($DatabaseName);User ID=sa;Password=ThisIsAReallyCoolPassword123;" | |
if($Result.Count -lt 1) | |
{ | |
Write-Host "No results returned!" | |
exit 1 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment