Unwanted log messages with shell=Powershell

Summary

With Gitlab-runner 15.6.0 and 15.6.1 for Windows, jobs produce unwanted job logs: #< CLIXML and <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs> at each step.

These logs are not present with Gitlab-runner 15.5.1.

Steps to reproduce

Every job that runs on shell powershell (not pwsh).

Example of jobs :

.gitlab-ci.yml
stages:          
  - test

shell-job:       
  stage: test
  # add tags to run this job with shell runner
  script:
    - Write-Host "hello"

docker-windows-job:
  stage: test
  # add tags to run this job with docker-windows runner
  image: mcr.microsoft.com/windows/servercore:ltsc2019
  script:
    - Write-Host "hello"

Actual behavior

docker-windows-job outputs:
Running with gitlab-runner 15.6.1 (133d7e76)
  on Exécuteur Docker Windows DFqX-Uui
section_start:1669734950:prepare_executor
Preparing the "docker-windows" executor
Using Docker executor with image mcr.microsoft.com/windows/servercore:ltsc2019 ...
Pulling docker image mcr.microsoft.com/windows/servercore:ltsc2019 ...
Using docker image sha256:4503e186c64d1c87f98c21e90a58566b00431bd8a47cca591ea1802ecd6fb389 for mcr.microsoft.com/windows/servercore:ltsc2019 with digest mcr.microsoft.com/windows/servercore@sha256:cbb8b0a709b4e0868cd2e30b1485358197b1021bb0dd4261e36b3af3ca48fd0b ...
section_end:1669734950:prepare_executor
section_start:1669734950:prepare_script
Preparing environment
#< CLIXML
Running on RUNNER-DFQX-UUI via 
SRV-GLR-DOCWIN1...
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>section_end:1669734991:prepare_script
section_start:1669734991:get_sources
Getting source from Git repository
#< CLIXML
$ git config --global --add safe.directory $CI_PROJECT_DIR.replace('c:','C:').replace('\', '/')
Fetching changes with git depth set to 20...
Initialized empty Git repository in C:/builds/morefa/test-runner-win/.git/
Created fresh repository.
Checking out b3d55ada as main...
git-lfs/3.2.0 (GitHub; windows amd64; go 1.18.2)

Skipping Git submodules setup
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>section_end:1669735037:get_sources
section_start:1669735037:step_script
Executing "step_script" stage of the job script
Using docker image sha256:4503e186c64d1c87f98c21e90a58566b00431bd8a47cca591ea1802ecd6fb389 for mcr.microsoft.com/windows/servercore:ltsc2019 with digest mcr.microsoft.com/windows/servercore@sha256:cbb8b0a709b4e0868cd2e30b1485358197b1021bb0dd4261e36b3af3ca48fd0b ...
#< CLIXML
$ Write-Host "hello"
hello
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>section_end:1669735077:step_script
section_start:1669735077:cleanup_file_variables
Cleaning up project directory and file based variables
#< CLIXML
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>section_end:1669735117:cleanup_file_variables
Job succeeded

Problems are the outputs #< CLIXML and <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>section_end:1669735117:cleanup_file_variables

Expected behavior

Same output, without #< CLIXML and <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>section_end:1669735117:cleanup_file_variables

Environment description

The problem is on a personal server, Windows Server 2019, with executor shell or docker-windows. Powershell with version 5.1.17763.2931, Gitlab-runner 15.6.0 ou 15.6.1.

config.toml
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "Shell runner"
  executor = "shell"
  shell = "powershell"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]

[[runners]]
  name = "Docker-Windows runner"
  executor = "docker-windows"
  pre_clone_script = "git config --global --add safe.directory $CI_PROJECT_DIR.replace('c:','C:').replace('\\', '/')"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
  [runners.docker]
    tls_verify = false
    image = "mcr.microsoft.com/windows/servercore:2019"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = true
    shm_size = 0

Runner version

Version: 15.6.1

Git revision: 133d7e76

Git branch: 15-6-stable

GO version: go1.18.8

Built: 2022-11-24T15:24:44+0000

OS/Arch: windows/amd64

Possible fixes

This problem is new to version 15.6.0. Using version 15.5.0 or 15.5.1 is a workaround.