Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,336 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Please help me to get it fixed.
Invoke-Sqlcmd returns a collection of DataRow objects, even when there's a single result. You're assigning this entire collection to $STATUS_CURRENTRUN, which is why you're seeing System.Data.DataRow. the following approach can work better for you
# Run the SQL query
$results = Invoke-Sqlcmd -Query "SELECT distinct STATUS_FLAG FROM LOGGING.DM_PROCESS_CONTROL_DETAIL WHERE PROJECT_FLAG='GEMS' ;" @params
# Extract the value (assuming STATUS_FLAG is the desired column)
if ($results.Count -gt 0) { # Ensure there's at least one result
$STATUS_CURRENTRUN = $results[0].STATUS_FLAG
} else {
# Handle case where there are no results (e.g., log an error)
Write-Warning "No results from the SQL query."
}