Our security have forced our laptops to use PowerShell 7 and uninstalled earlier versions of Powershell. Unfortunately PS7 executable is not powershell.exe but pwsh.exe. So when I try to run Vagrant I get this:
Vagrant failed to initialize at a very early stage:
Failed to locate the powershell executable on the available PATH. Please
ensure powershell is installed and available on the local PATH, then
run the command again.
Is there a way to tell Vagrant to use PS7?
That problem made me curious and therefore I installed Powershell 7.
However during my search about how to deinstall the old PowerShell 5.1 I found out it is a bad idea because a lot of tools that are required by windows are implemented as powershell scripts and not all powershell modules are compatible with the new 7 version. So deinstallation will make your system unstable.
My guess is that you still have the old
powershell.exe but it is missing in the
PATH environment variable.
So I would recommend doing the following things:
- Check if powershell.exe is somewhere on you system. Normally it is in
powershell.exe to your
PATH environment variable
Thanks for your response.
Yes you are correct our security guys didn’t actually removed powershell 5.1 entirely. But somehow they disabled it. So when I try to run it from command line nothing happens. When I used it with Vagrant I would get an error in openProcess module, so I removed it from the PATH so Powershell 7 would be used. ( I can’t give exact error, to add it back to PATH I need security people to help me ).
I guess I will need to go back to our security peop0le and beg them to fix Powershell 5.1
For me it sounds like the security people have removed the right to execute
powershell.exe which is why nothing happens on commandline and why vagrant fails.
They only idea I have so far is creating a hardlink to
pwsh.exe and name it
powershell.exe. If the powershell functionality that vagrant needs is also available in PowerShell Core (pwsh.exe) it might fixes your specific problem.
As much as I would like to help I can’t do this without further informations about your environment. Because your environment is administrated by the security people I would also recommended to figure it out with them.