Skip to content

Instantly share code, notes, and snippets.

@phillipsj
Last active October 17, 2020 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phillipsj/aee9a2484ecd2bc44bfff1bcb49bffb2 to your computer and use it in GitHub Desktop.
Save phillipsj/aee9a2484ecd2bc44bfff1bcb49bffb2 to your computer and use it in GitHub Desktop.
Really simple test for a database.
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