[GH-ISSUE #2545] PowerShell steps load profile during execution #1166

Closed
opened 2026-03-01 21:49:25 +03:00 by kerem · 5 comments
Owner

Originally created by @HeyItsGilbert on GitHub (Nov 26, 2024).
Original GitHub issue: https://github.com/nektos/act/issues/2545

Expected Behavior

Running a PowerShell script or command should run in it's own process without a profile being loaded.

Current Behavior

Currently the invocation runs powershell.exe -command . {0} where the commands are replaced in.

Possible Solution

Append -NoProfile to the powershell/pwsh calls.`

Steps to Reproduce

  1. On the instance running the command create a profile.
  2. Create a github workflow that runs powershell.
on:
  push:
jobs:
  test:
    runs-on: windows-latest
  steps:
    - run: |
      Write-Host "Hello world"
  1. Run act on the workflow while using -self-hosted
    • act --platform windows-latest=-self-hosted --workflows "./.github/workflows/helloworld.yaml"
  2. See error

Context

We are currently attach with -P windows=self-host on a windows machine.

Originally created by @HeyItsGilbert on GitHub (Nov 26, 2024). Original GitHub issue: https://github.com/nektos/act/issues/2545 ## Expected Behavior Running a PowerShell script or command should run in it's own process without a profile being loaded. ## Current Behavior Currently the invocation runs `powershell.exe -command . {0}` where the commands are replaced in. ## Possible Solution Append `-NoProfile` to the powershell/pwsh calls.` ## Steps to Reproduce 1. On the instance running the command create a profile. - See https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7.4#how-to-create-a-profile - Add something like `throw 'An error in your profile'` 2. Create a github workflow that runs powershell. ```yaml filename="helloworld.yaml" on: push: jobs: test: runs-on: windows-latest steps: - run: | Write-Host "Hello world" ``` 3. Run act on the workflow while using `-self-hosted` - `act --platform windows-latest=-self-hosted --workflows "./.github/workflows/helloworld.yaml"` 5. See error ## Context We are currently attach with `-P windows=self-host` on a windows machine.
kerem closed this issue 2026-03-01 21:49:26 +03:00
Author
Owner

@HeyItsGilbert commented on GitHub (Nov 26, 2024):

Probably should be associated with #1608

<!-- gh-comment-id:2502095217 --> @HeyItsGilbert commented on GitHub (Nov 26, 2024): Probably should be associated with #1608
Author
Owner

@ChristopherHX commented on GitHub (Nov 27, 2024):

My expected behavior is to keep this in sync with the actions/runner program

shell: powershell.exe -NoProfile -command . '{0}' is well supported by both

<!-- gh-comment-id:2504277870 --> @ChristopherHX commented on GitHub (Nov 27, 2024): My expected behavior is to keep this in sync with the actions/runner program `shell: powershell.exe -NoProfile -command . '{0}'` is well supported by both
Author
Owner

@HeyItsGilbert commented on GitHub (Nov 27, 2024):

I can totally understand why you would want to do that. I don't think they worry about that since they would never have profiles (that I know of). Nor would this ever be an issue on containers. The problem is when you run this on a local machine.

It feels like a bad trade off for users to have to edit all their workflows vs adding an additional flag. If you're keeping this in sync programmatically then I can try to submit the PR to the actions/runner repository.

<!-- gh-comment-id:2504306630 --> @HeyItsGilbert commented on GitHub (Nov 27, 2024): I can totally understand why you would want to do that. I don't think they worry about that since they would never have profiles (that I know of). Nor would this ever be an issue on containers. The problem is when you run this on a local machine. It feels like a bad trade off for users to have to edit all their workflows vs adding an additional flag. If you're keeping this in sync programmatically then I can try to submit the PR to the actions/runner repository.
Author
Owner

@HeyItsGilbert commented on GitHub (Nov 27, 2024):

I think I may have found a compromise. Since the env contains ACT, users can use that to skip loading potentially conflicting profiles.

<!-- gh-comment-id:2504364847 --> @HeyItsGilbert commented on GitHub (Nov 27, 2024): I think I may have found a compromise. Since the env contains `ACT`, users can use that to skip loading potentially conflicting profiles.
Author
Owner

@tablackburn commented on GitHub (Mar 25, 2025):

Here's an example based on what I added to my profile

if ($env:ACT -eq $True) {
    # This code will run when executed by ACT
}
else {
    # This code will run when executed by anything other than ACT
}
<!-- gh-comment-id:2751966826 --> @tablackburn commented on GitHub (Mar 25, 2025): Here's an example based on what I added to my profile ```powershell if ($env:ACT -eq $True) { # This code will run when executed by ACT } else { # This code will run when executed by anything other than ACT } ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#1166
No description provided.