File tree Expand file tree Collapse file tree 2 files changed +35
-4
lines changed
TaskModules/powershell/TaskModuleSqlUtility Expand file tree Collapse file tree 2 files changed +35
-4
lines changed Original file line number Diff line number Diff line change 1- # Function to import SqlPS module & avoid directory switch
1+ $featureFlags = @ {
2+ enableVerboseLogging = [System.Convert ]::ToBoolean($env: ENABLE_VERBOSE_LOGGING )
3+ }
4+ # Function to import SqlPS module & avoid directory switch
25function Import-SqlPs {
36 push-location
47 Import-Module SqlPS - ErrorAction ' SilentlyContinue' | out-null
@@ -86,10 +89,38 @@ function Invoke-SqlQueryDeployment
8689 }
8790
8891 $additionalArguments = EscapeSpecialChars $additionalArguments
92+ if ($featureFlags.enableVerboseLogging ) {
93+ $commandToRun = $commandToLog + " " + $additionalArguments
94+ $command = " Invoke-SqlCmd @spaltArguments $additionalArguments "
95+ Write-Host " ##[command] $commandToRun "
96+
97+ if ($additionalArguments.ToLower ().Contains(" -verbose" )) {
98+ $errors = @ ()
8999
90- Write-Verbose " Invoke-SqlCmd arguments : $commandToLog $additionalArguments "
91- Invoke-Expression " Invoke-SqlCmd @spaltArguments $additionalArguments "
100+ Invoke-Expression $command - ErrorVariable errors 4>&1 | ForEach-Object {
101+ Write-Host $_
102+ }
92103
104+ if ($errors.Count -gt 0 ) {
105+ throw
106+ }
107+ }
108+ else {
109+ Invoke-Expression $command
110+ }
111+ }
112+ else {
113+ Write-Verbose " Invoke-SqlCmd arguments : $commandToLog $additionalArguments "
114+ Invoke-Expression " Invoke-SqlCmd @spaltArguments $additionalArguments "
115+ }
116+ }
117+ Catch {
118+ if ($featureFlags.enableVerboseLogging ) {
119+ Write-VstsSetResult - Result ' Failed' - Message " Error detected" - DoNotThrow
120+ }
121+ else {
122+ throw $_.Exception
123+ }
93124 } # End of Try
94125 Finally
95126 {
Original file line number Diff line number Diff line change 11@ {
22 RootModule = ' TaskModuleSqlUtility.psm1'
3- ModuleVersion = ' 0.1.3 '
3+ ModuleVersion = ' 0.1.6 '
44 GUID = ' d997c6dd-33ad-481c-859b-01120229b91f'
55 Author = ' Microsoft'
66 CompanyName = ' Microsoft'
You can’t perform that action at this time.
0 commit comments