Skip to content

[Bug]: Saltstack onedir powershell -File param #69959

Description

@vegcom

What happened?

Saltstack onedir powershell -File param bug

On Windows, Saltstack onedir always invokes Windows PowerShell 5.1, even when pwsh is installed.
PowerShell 5.1 rejects the -File parameter in this invocation, producing the misleading error:

"The argument '' to the -File parameter does not exist."

This is not a missing temp file — the file exists. The failure occurs because the -File
parameter is not supported by the version of PowerShell that onedir is invoking.

May be temp file handling.


You can view my salt environment at: https://github.com/vegcom/cozy-salt

Output

Windows version

➜  Get-ComputerInfo | Select-Object OsName, OsVersion

OsName                   OsVersion
------                   ---------
Microsoft Windows 11 Pro 10.0.26200
➜  Get-ComputerInfo | Select-Object WindowsProductName, WindowsVersion, OsHardwareAbstractionLayer

WindowsProductName WindowsVersion OsHardwareAbstractionLayer
------------------ -------------- --------------------------
Windows 10 Pro     2009           10.0.26100.1

Pwsh Version

sudo salt-call cmd.powershell '$PSVersionTable.PSVersion'
local:
    ----------
    Build:
        26100
    Major:
        5
    MajorRevision:
        0
    Minor:
        1
    MinorRevision:
        8972
    Revision:
        8972

Saltstack

This is a snip not the entire state. this was from cozy-salt salt-call state.sls windows.install on a windows 11 machine.

[INFO    ] Fetching file from saltenv 'base', ** done ** 'windows/files/opt-cozy-bin/winget-batch.ps1'
[DEBUG   ] ['C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.EXE', '-NonInteractive', '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', 'C:\\Users\\<user>\\AppData\\Local\\Temp\\__salt.tmp.08yacrs6.ps1', '-WingetPath', 'C:\\Users\\<user>\\AppData\\Local\\Microsoft\\WindowsApps\\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\\winget.exe', '-Packages', 'evsar3.sshfs-win-manager', '-Scope', 'user', '-SkipDeps', 'false', '-Prerelease', 'false', '-Force', 'false', '-Upgrade', 'false']
[INFO    ] No changes made for winget_batch_userland_<user>_networking
[INFO    ] Completed state [winget_batch_userland_<user>_networking] at time 11:25:07.426979 (duration_in_ms=82.899)
[INFO    ] Running state [winget_batch_userland_<user>_utilities] at time 11:25:07.427881
[INFO    ] Executing state cmd.script for [winget_batch_userland_<user>_utilities]
[DEBUG   ] In saltenv 'base', looking at rel_path 'windows/files/opt-cozy-bin/winget-batch.ps1' to resolve 'salt://windows/files/opt-cozy-bin/winget-batch.ps1'
[DEBUG   ] In saltenv 'base', ** considering ** path 'C:\ProgramData\Salt Project\Salt\var\cache\salt\minion\files\base\windows\files\opt-cozy-bin\winget-batch.ps1' to resolve 'salt://windows/files/opt-cozy-bin/winget-batch.ps1'
[DEBUG   ] Fetching file from saltenv 'base', ** attempting ** 'salt://windows/files/opt-cozy-bin/winget-batch.ps1'
[DEBUG   ] No dest file found
The argument 'C:\Users\<user>\AppData\Local\Temp\__salt.tmp.gjdcqec_.ps1' to the -File parameter does not exist. Provide the path to an existing '.ps1' file as an argument to the -File parameter.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
[INFO    ] Fetching file from saltenv 'base', ** done ** 'windows/files/opt-cozy-bin/winget-batch.ps1'
[DEBUG   ] ['C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.EXE', '-NonInteractive', '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', 'C:\\Users\\<user>\\AppData\\Local\\Temp\\__salt.tmp.kga44l2f.ps1', '-WingetPath', 'C:/Program Files/WindowsApps/Microsoft.DesktopAppInstaller_1.29.280.0_x64__8wekyb3d8bbwe/winget.exe', '-Packages', 'Microsoft.WindowsADK,Microsoft.NuGet', '-Scope', 'machine', '-SkipDeps', 'false', '-Prerelease', 'false', '-Force', 'false', '-Upgrade', 'false']
[INFO    ] No changes made for winget_batch_runtimes_sdks
[INFO    ] Completed state [winget_batch_runtimes_sdks] at time 12:17:50.010963 (duration_in_ms=81.663)
[INFO    ] Running state [winget_batch_runtimes_ui_libraries] at time 12:17:50.012041
[INFO    ] Executing state cmd.script for [winget_batch_runtimes_ui_libraries]
[DEBUG   ] In saltenv 'base', looking at rel_path 'windows/files/opt-cozy-bin/winget-batch.ps1' to resolve 'salt://windows/files/opt-cozy-bin/winget-batch.ps1'
[DEBUG   ] In saltenv 'base', ** considering ** path 'C:\ProgramData\Salt Project\Salt\var\cache\salt\minion\files\base\windows\files\opt-cozy-bin\winget-batch.ps1' to resolve 'salt://windows/files/opt-cozy-bin/winget-batch.ps1'
[DEBUG   ] Fetching file from saltenv 'base', ** attempting ** 'salt://windows/files/opt-cozy-bin/winget-batch.ps1'
[DEBUG   ] No dest file found
The argument 'C:\Users\<user>\AppData\Local\Temp\__salt.tmp.wgqsjue3.ps1' to the -File parameter does not exist. Provide the path to an existing '.ps1' file as an argument to the -File parameter.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Type of salt install

other (please specify in bug details)

Major version

3008.x

What supported OS are you seeing the problem on? Can select multiple. (If bug appears on an unsupported OS, please open a GitHub Discussion instead)

windows-desktop-11

salt --versions-report output

local:
    Salt Version:
              Salt: 3008.2

    Python Version:
            Python: 3.14.6 (heads/main:780a303, Jun 11 2026, 02:09:15) [MSC v.1944 64 bit (AMD64)]

    Dependency Versions:
              cffi: 2.1.1
          cherrypy: 18.10.0
      cryptography: 50.0.0
          dateutil: 2.9.0.post0
         docker-py: Not Installed
             gitdb: 4.0.12
         gitpython: 3.1.57
            Jinja2: 3.1.6
           libgit2: Not Installed
      looseversion: 1.3.0
          M2Crypto: Not Installed
              Mako: Not Installed
           msgpack: 1.2.1
      msgpack-pure: Not Installed
      mysql-python: Not Installed
         packaging: 26.2
         pycparser: 3.00
          pycrypto: Not Installed
      pycryptodome: 3.23.0
            pygit2: Not Installed
      python-gnupg: 0.5.6
            PyYAML: 6.0.3
             PyZMQ: 27.1.0
            relenv: 0.22.14
             smmap: 5.0.2
           timelib: 0.3.0
           Tornado: 6.5.7
               ZMQ: 4.3.5

    Salt Package Information:
      Package Type: onedir

    System Versions:
              dist:
            locale: utf-8
           machine: AMD64
           release: 10
            system: Windows
           version: 10 10.0.26200 SP0 Multiprocessor Free

Metadata

Metadata

Assignees

Labels

bugbroken, incorrect, or confusing behavior

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions