Set Powershell v7 as default

Handian Sudianto 7,571 Reputation points
2026-10-12T03:21:39.6333333+00:00

I have solarwinds Server & Application Monitor (SAM) where we can make custom powershell to be executed from SAM.

I have a script to connect to the azure to get some information and the script is can't work if use old powershell v5 but working normally when use powershell v7. Since powershell v5 is default in the OS then when SAM running the script then powershell v5 is used.

Can we change default version of powershell from v5 to v7, so when SAM execute the script then v7 will be used?

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments

2 answers

Sort by: Most helpful
  1. Deepesh Dhake 1,245 Reputation points
    2026-10-12T17:41:14.34+00:00

    No, you can’t change it. SAM's PowerShell monitor is fixed to 5.1, and SAM has no setting to choose the version.

    The workaround is to have the SAM script call pwsh.exe:

    $out = & "C:\Program Files\PowerShell\7\pwsh.exe" -NoProfile -NonInteractive -File "C:\Scripts\AzureCheck.ps1" 2>&1
    $code = $LASTEXITCODE
    $out | ForEach-Object { Write-Host $_ }
    exit $code
    

    The child script should authenticate to Azure with a service principal or managed identity, since it runs under the SAM credential, not your account.

    Was this answer helpful?

    0 comments No comments

  2. Chen Tran 13,435 Reputation points Independent Advisor
    2026-10-12T04:55:09.3+00:00

    Hello Handian,

    Thank you for posting question on Microsoft Windows Forum!

    Well! The fact of the matter is that you cannot simply change a system-wide "default" PowerShell version from v5 to v7 on Windows. Windows does not have a central setting to make PowerShell 7 the default over the built-in Windows PowerShell 5.1. They are designed to coexist as separate applications. PowerShell 7 is installed as a new, side-by-side application and does not replace the older version. The powershell.exe command always launches the v5.1 engine, while pwsh.exe is the command for PowerShell 7. Since SolarWinds SAM typically calls powershell.exe by default, it uses v5.1.

    Since you cannot change the system default, the suggestion is to make the SAM component monitor call the PowerShell 7 executable directly. You can try to create a new PowerShell script (e.g., Run-AzureScript.ps1) on the SAM server or target node. Inside this wrapper script, use Start-Process to call the full path to pwsh.exe, passing your original script and its arguments. In your SolarWinds SAM Windows PowerShell Monitor template, point the "Script" or "Command Line" field to execute this new wrapper script using the standard powershell.exe. The wrapper will then launch PowerShell 7 to do the actual work.

    I hope you have found something useful here. If it helps you get more insight into the issue, it is appreciated to accept the answer. Should you have more questions, feel free to leave a message. Have a nice day!

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.