I have chosen a default profile that’s using the modern pwsh (7.5.0+) but the agent is still issuing commands in old Microsoft PowerShell confirmed with $PSVersionTable.PSVersion
Steps to Reproduce
Install modern PowerShell and change default profile and then ask an agent to run $PSVersionTable.PSVersion
Expected Behavior
$PSVersionTable.PSVersion when executed by an agent report
Major Minor Patch PreReleaseLabel BuildLabel
7 5 4
Operating System
Windows 10/11
Current Cursor Version (Menu → About Cursor → Copy)
The trick is making sure that pwsh.exe comes first in the PATH before powershell.exe. Your milage may vary based on your setup.
This is the little script that Cursor wrote for me to do that (run as administrator)
# Script to reorder PATH so pwsh.exe (PowerShell 7) comes before powershell.exe (Windows PowerShell 5.1)
# This script must be run as Administrator
# Check if running as admin
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
Write-Host "ERROR: This script must be run as Administrator!" -ForegroundColor Red
Write-Host "Right-click PowerShell and select 'Run as Administrator', then run this script again." -ForegroundColor Yellow
exit 1
}
Write-Host "Reading current system PATH..." -ForegroundColor Cyan
$systemPath = [Environment]::GetEnvironmentVariable("Path", "Machine") -split ';' | Where-Object { $_ -ne '' }
Write-Host "`nCurrent PATH order (PowerShell-related entries):" -ForegroundColor Yellow
$systemPath | Select-String -Pattern 'PowerShell|powershell' | ForEach-Object { Write-Host " $_" }
# Reorder: PowerShell 7 first, then everything else (keeping all entries including duplicates)
Write-Host "`nReordering PATH..." -ForegroundColor Cyan
$newSystemPath = @()
$newSystemPath += $systemPath | Where-Object { $_ -like 'C:\Program Files\PowerShell\7*' }
$newSystemPath += $systemPath | Where-Object { $_ -notlike 'C:\Program Files\PowerShell\7*' }
$newSystemPathString = $newSystemPath -join ';'
Write-Host "Updating system PATH..." -ForegroundColor Cyan
[Environment]::SetEnvironmentVariable("Path", $newSystemPathString, "Machine")
Write-Host "`nPATH updated successfully!" -ForegroundColor Green
Write-Host "`nNew PATH order (PowerShell-related entries):" -ForegroundColor Yellow
$newSystemPath | Select-String -Pattern 'PowerShell|powershell' | ForEach-Object { Write-Host " $_" }
Write-Host "`nNote: You may need to restart your terminal or log out/in for changes to take full effect." -ForegroundColor Cyan
It would be handy if there was a better way to define what shell you want to use (noted).