# \[powershelldre:S8677\] Write-Host to set set pipeline variables in a script

**URL:** <https://community.sonarsource.com/t/powershelldre-s8677-write-host-to-set-set-pipeline-variables-in-a-script/186161>\
**Category:** Rules and Languages\
**Tags:** azuredevops, false-positive\
**Created:** [July 18, 2026, 9:52am UTC](https://community.sonarsource.com/t/powershelldre-s8677-write-host-to-set-set-pipeline-variables-in-a-script/186161 "2026-07-18T09:52:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![milbrandt](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/milbrandt/32/3726_2.png) [@milbrandt](https://community.sonarsource.com/u/milbrandt)\
**Post date:** [July 18, 2026, 9:52am UTC](https://community.sonarsource.com/t/powershelldre-s8677-write-host-to-set-set-pipeline-variables-in-a-script/186161/1 "2026-07-18T09:52:04Z")

</div>

Inside a Powershell script.ps1 file, which is called from an azure-pipeline.yml some pipeline variables are set.

According [Set variableproperties](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/set-variables-scripts?view=azure-devops&tabs=powershell#set-variable-properties) and [Logging command format](https://learn.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?view=azure-devops&tabs=powershell#logging-command-format) output must go to standard output. Documentation uses `Write-Host` command.

```yml
          - task: PowerShell@2
            inputs:
              pwsh: true
              targetType: inline
              script: |
                $packageListJson = '${{ convertToJson(parameters.vcpkgPackageList) }}'

                & "scripts\script.ps1" `
                  -PackageListJson $packageListJson `
            env:
              PATH: $(VSDEV_PATH)
              INCLUDE: $(VSDEV_INCLUDE)
              LIB: $(VSDEV_LIB)
              LIBPATH: $(VSDEV_LIBPATH)

```

```powershell
param(
    [Parameter(Mandatory = $true)]
    [string]$PackageListJson)

...

    if ($LASTEXITCODE -ne 0) {
        # powershelldre:S8677 emitted by next line
        Write-Host ("##vso[task.logissue type=warning]Drift check: REF '$Ref' is not reachable ")
        # Return a non-empty sentinel so the caller detects changes and validates the version.
        return @(" __ref-not-reachable__")
    }

```

Proposal: exception to the rule, if `##vso[...]` or `##[...]` pattern in stdout

---

<div class="post-metadata">

**Author:** ![asya.vorobeva](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@asya.vorobeva](https://community.sonarsource.com/u/asya.vorobeva)\
**Post date:** [July 24, 2026, 7:37am UTC](https://community.sonarsource.com/t/powershelldre-s8677-write-host-to-set-set-pipeline-variables-in-a-script/186161/3 "2026-07-24T07:37:31Z")

</div>

Hello, thanks for feedback, we created JIRA ticket to fix this FP.
