Public/InstallHelpers/Install.Database.Functions.psm1
Set-StrictMode -Version Latest $ErrorActionPreference = "Stop"; #Requires -Version 5.0 # NOTE: This function depends on the dbatools module # TODO: Ensure dbatools is installed function DropDatabase( [Parameter(mandatory=$true)] [System.Management.Automation.PSCredential] $credential, [Parameter(mandatory=$false)] [string] $dbHost = $testDbHost, [Parameter(mandatory=$true)] [string] $dbName ) { # TODO: Can I Parameterize this? (I don't think so...) [string] $dropDbSql = @" USE [master] GO IF DB_ID('$dbName') IS NOT NULL BEGIN DROP DATABASE [$dbName] END "@ # DOCS: https://docs.dbatools.io/#Invoke-DbaQuery $result = Invoke-DbaQuery ` -SqlInstance $dbHost ` -Query $dropDbSql ` -SqlCredential $credential Write-Host $result # TODO: Handle errors with exit 1 } Export-ModuleMember -Function "*" |