Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Function to import SqlPS module & avoid directory switch
$featureFlags = @{
enableVerboseLogging = [System.Convert]::ToBoolean($env:ENABLE_VERBOSE_LOGGING)
}
# Function to import SqlPS module & avoid directory switch
function Import-SqlPs {
push-location
Import-Module SqlPS -ErrorAction 'SilentlyContinue' | out-null
Expand Down Expand Up @@ -86,10 +89,38 @@ function Invoke-SqlQueryDeployment
}

$additionalArguments = EscapeSpecialChars $additionalArguments
if ($featureFlags.enableVerboseLogging) {
$commandToRun = $commandToLog + " " + $additionalArguments
$command = "Invoke-SqlCmd @spaltArguments $additionalArguments"
Write-Host "##[command] $commandToRun"

if ($additionalArguments.ToLower().Contains("-verbose")) {
$errors = @()

Write-Verbose "Invoke-SqlCmd arguments : $commandToLog $additionalArguments"
Invoke-Expression "Invoke-SqlCmd @spaltArguments $additionalArguments"
Invoke-Expression $command -ErrorVariable errors 4>&1 | ForEach-Object {
Write-Host $_
}

if ($errors.Count -gt 0) {
throw
}
}
else {
Invoke-Expression $command
}
}
else {
Write-Verbose "Invoke-SqlCmd arguments : $commandToLog $additionalArguments"
Invoke-Expression "Invoke-SqlCmd @spaltArguments $additionalArguments"
}
}
Catch {
if ($featureFlags.enableVerboseLogging) {
Write-VstsSetResult -Result 'Failed' -Message "Error detected" -DoNotThrow
}
else {
throw $_.Exception
}
} # End of Try
Finally
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@{
RootModule = 'TaskModuleSqlUtility.psm1'
ModuleVersion = '0.1.3'
ModuleVersion = '0.1.6'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this value?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In PS gallery, the current version of TaskModuleSqlUtility is 0.1.5, so I set the new version to 0.1.6.

GUID = 'd997c6dd-33ad-481c-859b-01120229b91f'
Author = 'Microsoft'
CompanyName = 'Microsoft'
Expand Down
Loading