Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
Expand Up @@ -87,9 +87,28 @@ function Invoke-SqlQueryDeployment

$additionalArguments = EscapeSpecialChars $additionalArguments

Write-Verbose "Invoke-SqlCmd arguments : $commandToLog $additionalArguments"
Invoke-Expression "Invoke-SqlCmd @spaltArguments $additionalArguments"
$commandToRun = $commandToLog + " " + $additionalArguments
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we consider adding this entire change under FF ?

Copy link
Author

Choose a reason for hiding this comment

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

Sure, added the entire change under the FF

$command = "Invoke-SqlCmd @spaltArguments $additionalArguments"

Write-Host "##[command] $commandToRun"
Copy link
Contributor

Choose a reason for hiding this comment

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

can you make a test if additional arguments contains secret if the agent will suppress those values?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, Razvan the agent is suppressing the value when the additional arguments contain secret, and the task is consuming its value.


if ($additionalArguments.ToLower().Contains("-verbose")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

don't we also have abbreviations like -v , or are there any possible arguments like -verbose:false

Copy link
Author

Choose a reason for hiding this comment

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

No, I don't believe that's the case. I tested using both -v and -verbose:false, and we didn't receive verbose output in the logs.

$errors = @()

$rawOutput = (Invoke-Expression $command -ErrorVariable errors 4>&1 | Out-String)
Copy link
Contributor

@manolerazvan manolerazvan Oct 17, 2025

Choose a reason for hiding this comment

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

wouldn't this introduce delays in providing output ? before with just invoke we would have live steaming but with this we will buffer the entire output until command finishes and after we will re-emit each line.

we will loose object types as everything is converted to plain text

Copy link
Author

Choose a reason for hiding this comment

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

Fixed the buffering the entire output in the next commit.

and the object type "loss" is intentional and appropriate since we're displaying results to users in logs, not passing data to other PowerShell code.

$trimmedOutput = $rawOutput.TrimEnd()
$trimmedOutput -split "`r?`n" | Where-Object { $_.Trim() -ne "" } | ForEach-Object { Write-Output $_ }

if ($errors.Count -gt 0) {
throw
}
}
else {
Invoke-Expression $command
}
}
Catch {
Write-VstsSetResult -Result 'Failed' -Message "Error detected" -DoNotThrow
} # 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