Powershell Instance Runner fails on Windows 7/8

Summary

When trying to use https://github.com/LukasK32/fleeting-plugin-proxmox with a Windows 7 Executor, the pipeline failed during the Preparing Environment step. As far as I know this is not an issue with the plugin, but the runner itself. This is also an issue with Server 2008R2, and Windows 8. I have already verified that Server 2012, Server 2012 R2, Windows 8.1, Windows 10, Windows 11, and Servers 2016-2025 work.

Steps to reproduce

Try and use the Proxmox fleeting plugin with a Windows 7 host. Note, that this might also be an issue on any runner that's not the shell or custom ones (I think the issue is adjacent to DisablePowershellStdin).

Actual behavior

Job fails during the Preparing environment step, with

'-' was specified as the argument to -Command but standard input has not been redirected for this process.
ERROR: Job failed: prepare environment: exit code 4294770688. Check https://docs.gitlab.com/runner/shells/#shell-profile-loading for more information.

Expected behavior

Job passes without error.

Relevant logs and/or screenshots

job log
[0KRunning with gitlab-runner 18.1.0 (0731d300)[0;m
[0K  on Windows7-SP1-x64 t1_7WvY5y, system ID: s_55759cdb8ed9[0;m
[0K[36;1mResolving secrets[0;m[0;m
section_start:1750531069:prepare_executor
[0K[0K[36;1mPreparing the "instance" executor[0;m[0;m
[0KPreparing instance...[0;m
[0KDialing instance 121...[0;m
[0KInstance 121 connected[0;m
section_end:1750531239:prepare_executor
[0Ksection_start:1750531239:prepare_script
[0K[0K[36;1mPreparing environment[0;m[0;m

PowerShell[.exe] [-PSConsoleFile <file> | -Version <version>]
    [-NoLogo] [-NoExit] [-Sta] [-NoProfile] [-NonInteractive]
    [-InputFormat {Text | XML}] [-OutputFormat {Text | XML}] 
    [-WindowStyle <style>] [-EncodedCommand <Base64EncodedCommand>] 
    [-File <filePath> <args>] [-ExecutionPolicy <ExecutionPolicy>]
    [-Command { - | <script-block> [-args <arg-array>]
                  | <string> [<CommandParameters>] } ]

PowerShell[.exe] -Help | -? | /?

-PSConsoleFile
    Loads the specified Windows PowerShell console file. To create a console
    file, use Export-Console in Windows PowerShell.

-Version
    Starts the specified version of Windows PowerShell.

-NoLogo
    Hides the copyright banner at startup.

-NoExit
    Does not exit after running startup commands.

-Sta
    Start the shell using a single-threaded apartment.

-NoProfile
    Does not use the user profile.

-NonInteractive
    Does not present an interactive prompt to the user.

-InputFormat
    Describes the format of data sent to Windows PowerShell. Valid values are
    "Text" (text strings) or "XML" (serialized CLIXML format).

-OutputFormat
    Determines how output from Windows PowerShell is formatted. Valid values
    are "Text" (text strings) or "XML" (serialized CLIXML format).

-WindowStyle
    Sets the window style to Normal, Minimized, Maximized or Hidden.

-EncodedCommand
    Accepts a base-64-encoded string version of a command. Use this parameter 
    to submit commands to Windows PowerShell that require complex quotation 
    marks or curly braces.

-File
    Execute a script file.

-ExecutionPolicy
    Sets the default execution policy for the session.

-Command
    Executes the specified commands (and any parameters) as though they were
    typed at the Windows PowerShell command prompt, and then exits, unless 
    NoExit is specified. The value of Command can be "-", a string. or a
    script block.

    If the value of Command is "-", the command text is read from standard
    input.

    If the value of Command is a script block, the script block must be enclosed
    in braces ({}). You can specify a script block only when running PowerShell.exe
    in Windows PowerShell. The results of the script block are returned to the
    parent shell as deserialized XML objects, not live objects.

    If the value of Command is a string, Command must be the last parameter
    in the command , because any characters typed after the command are 
    interpreted as the command arguments.

    To write a string that runs a Windows PowerShell command, use the format:
	"& {<command>}"
    where the quotation marks indicate a string and the invoke operator (&)
    causes the command to be executed.

-Help, -?, /?
    Shows this message. If you are typing a PowerShell.exe command in Windows
    PowerShell, prepend the command parameters with a hyphen (-), not a forward
    slash (/). You can use either a hyphen or forward slash in Cmd.exe.

EXAMPLES
    PowerShell -PSConsoleFile SqlSnapIn.Psc1
    PowerShell -version 1.0 -NoLogo -InputFormat text -OutputFormat XML
    PowerShell -Command {Get-EventLog -LogName security}
    PowerShell -Command "& {Get-EventLog -LogName security}"

    # To use the -EncodedCommand parameter:
    $command = 'dir "c:\program files" '
    $bytes = [System.Text.Encoding]::Unicode.GetBytes($command)
    $encodedCommand = [Convert]::ToBase64String($bytes)
    powershell.exe -encodedCommand $encodedCommand
'-' was specified as the argument to -Command but standard input has not been redirected for this process.
section_end:1750531239:prepare_script
[0K[31;1mERROR: Job failed: prepare environment: exit code 4294770688. Check https://docs.gitlab.com/runner/shells/#shell-profile-loading for more information
[0;m

Environment description

This is an on-prem instance of Gitlab. I am using gitlab-runner 18.1.0.

config.toml contents
concurrent = 1
check_interval = 0
shutdown_timeout = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "Windows7-SP1-x64"
  url = "http://<gitlab-instance>"
  id = 23
  token = "<token>"
  token_obtained_at = 2025-06-21T17:55:00Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "instance"
  shell = "powershell"
  [runners.cache]
    MaxUploadedArchiveSize = 0
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
[runners.autoscaler]
  plugin = "ghcr.io/lukask32/fleeting-plugin-proxmox:1.2.0"
[runners.autoscaler.plugin_config]
  url = "<url>"
  insecure_skip_tls_verify = true
  credentials_file_path = "/etc/gitlab-runner/credentials.json"
  pool = "<pool>"
  template_id = <vmid>
  max_instances = 2
  instance_name_creating = "Windows7-SP1-x64-creating"
  instance_name_running = "Windows7-SP1-x64-running"
  instance_name_removing = "Windows7-SP1-x64-removing"
  instance_network_interface = "Local Area Connection"
[runners.autoscaler.connector_config]
  os = "windows"
  arch = "amd64"
  username = "<username>"
  password = "<password>"
  use_static_credentials = true
  protocol = "winrm"
  protocol_port = 5985
.gitlab-ci.yml
windows:
  stage: test
  script:
      - Write-Host "Test"
  parallel:
    matrix:
      - BUILD_OS:
          - Windows7-SP1 # FIXME:
          - Windows8 # FIXME:
          - Windows81
          - Windows10-22H2
        BUILD_ARCH:
          - x86
      - BUILD_OS:
          - Windows7-SP1 # FIXME:
          - Windows8 # FIXME:
          - Windows81
          - Windows10-22H2
          - Windows11-24H2
        BUILD_ARCH:
          - x64
  tags:
    - ${BUILD_OS}-${BUILD_ARCH}

Used GitLab Runner version

Version:      18.1.0
Git revision: 0731d300
Git branch:   18-1-stable
GO version:   go1.24.3 X:cacheprog
Built:        2025-06-19T16:44:14Z
OS/Arch:      linux/amd64

Possible fixes

I think it has something to do with this: https://gitlab.com/gitlab-org/gitlab-runner/-/blob/main/shells/powershell.go?ref_type=heads#L721

Edited by Kraust