fix executionpolicy with pwsh

This commit is contained in:
Nathan
2025-12-19 11:33:04 -07:00
parent 658052cae4
commit 4d1b554f8f
2 changed files with 120 additions and 1 deletions

View File

@@ -2661,3 +2661,122 @@ Note: The checksum errors suggest `Get-FileHash` isn't available, possibly due t
---
_**User**_
how do I make it use the proper ExecutionPolicy?
---
_**Agent (model default, mode Agent)**_
Updating the batch file to check and set the execution policy if needed, or use a more appropriate policy:
---
<tool-use data-tool-type="read" data-tool-name="read_file_v2">
<details><summary>Tool use: **read_file_v2** • Read file: a:\1 Amazon_Active_Projects\3 ProjectStructure\organize_textures.bat</summary>
</details>
</tool-use>
---
Updating the batch file to set the execution policy properly:
---
<tool-use data-tool-type="unknown" data-tool-name="edit_file_v2">
<details>
<summary>Tool use: **edit_file_v2**</summary>
Parameters:
```json
{
"relativeWorkspacePath": "a:\\1 Amazon_Active_Projects\\3 ProjectStructure\\organize_textures.bat"
}
```
Additional data:
```json
{
"codeblockId": "62340c40-576d-41f2-9ad8-86a073e36d56"
}
```
Status: **completed**
</details>
</tool-use>
---
Updating the batch file to set the execution policy only if needed:
---
<tool-use data-tool-type="unknown" data-tool-name="edit_file_v2">
<details>
<summary>Tool use: **edit_file_v2**</summary>
Parameters:
```json
{
"relativeWorkspacePath": "a:\\1 Amazon_Active_Projects\\3 ProjectStructure\\organize_textures.bat"
}
```
Additional data:
```json
{
"codeblockId": "828ef4e1-65ea-4738-9ac8-507e09ec852c"
}
```
Status: **completed**
</details>
</tool-use>
---
The batch file now checks the current user's execution policy and sets it to `RemoteSigned` if it's `Restricted`. This allows local scripts to run without bypassing the policy each time.
If you prefer to bypass the policy only for this script run (without changing system settings), we can revert to using `-ExecutionPolicy Bypass` for the current process only. The current approach sets a proper policy for your user account.
Note: The `Get-FileHash` errors are likely due to an older PowerShell version (requires 4.0+) or the cmdlet not being available, not an execution policy issue.
---
_**User**_
@pwsh (4-12)
---
_**Agent (model default, mode Agent)**_
Switching the batch file to use `pwsh` (PowerShell Core) instead of `powershell`, and simplifying the execution policy handling:
---
<tool-use data-tool-type="read" data-tool-name="read_file_v2">
<details><summary>Tool use: **read_file_v2** • Read file: a:\1 Amazon_Active_Projects\3 ProjectStructure\organize_textures.bat</summary>
</details>
</tool-use>
---