pwsh.exe executable does not work in Windows Task Scheduler
See original GitHub issueHi,
I was using powershell.exe for my current script in task scheduler without problems. I installed Powershell 7.1 through Microsoft Store and when I look at add/remove files I see it as installed. When I changed the program/script to pwsh.exe I started getting file not found errors, reading issue #13302, I thought it was the path that was the problem. When I run where pwsh.exe I get 2 paths:
1) C:\Program Files\WindowsApps\Microsoft.PowerShell_7.1.0.0_x64__8wekyb3d8bbwe\pwsh.exe
2) C:\Users\user1\AppData\Local\Microsoft\WindowsApps\pwsh.exe
Looking at user1’s Path, I see no 2, which provides why it runs interactively. Looking at system path, none are listed, which is why task scheduler fails. I am not clear on how to solve this. if I enter no 1 in system’s path, whenever application is automatically upgraded, it will become invalid and script will fail. if I enter no 2, it depends on user1 being available which I think is the best approach.
Could somebody propose the best action here?
Environment data
Name Value
PSVersion 7.1.0 PSEdition Core GitCommitId 7.1.0 OS Microsoft Windows 10.0.18363 Platform Win32NT
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
That is a remarkably silly conclusion in my view.
I have Pwsh 7.1 installed on a bunch of domain servers and all can use it just fine even with task scheduler. Try using the Install-PowerShell script on GitHub. Get it at https://github.com/PowerShell/PowerShell/blob/master/tools/install-powershell.ps1. If you have to install it from the store, re-read the post avoce from @jborean93 which shows how you can resolve your issue.
IMHO, the store is for consumer apps on Windows client devices. If you want to manage a domain and do grown up stuff, install PowerShell 7 from the real source. Chocolately is a non-supported repository. If support matters, use a more supported approach.
Basicly what you are saying, If you want to use PS 7.x from Microsoft store (that automatically upgrades itself) you can’t use it from Task Scheduler. <sigh> back to chocolatey then.