PowerShell deleted :( - how to fix local ps-scripts (local checks) that don't working anymore

Hey,

because of issues with the vCenter we have installed a newer version of the PowerShell (7) on a windows (server) host. We thought, now that we have the newer version we can uninstall/delete the old that comes with windows itself (thought it was 1.x).

After we have uninstalled and also deleted the 1.x files in the PowerShell directories, the check_mk checks that require PowerShell don’t work anymore (for example check_mk-windows_tasks or our own local-scripts).

We have reinstalled the old PowerShell and copied the files back to the directories but that didn’t fixed the problem.

Any suggestion what we can do except from reinstall the whole VM. Or get the cmk-agent to work with the newer PowerShell version ?

thx :slight_smile:

Josef

The problem is - what happens if you call “powershell.exe” without any path on a cmd windows?
If you get an error message, you know why CMK cannot execute PS1 scripts.
The installed Powershell7 is started with pwsh.exe.

pwsh -command "$PSVersionTable"

Name                           Value
----                           -----
PSVersion                      7.3.6
PSEdition                      Core
GitCommitId                    7.3.6
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0


powershell -command "$PSVersionTable"

Name                           Value
----                           -----
PSVersion                      5.1.22621.1778
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22621.1778
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Technically the scripts should also run with “pwsh.exe” instead of “powershell.exe”.
Only if the script uses external module you will have a problem.

1 Like

Danke für die schnelle Antowort.
Wenn wir die PowerShell von der CMD aus starten möchten bekommen wir diesen Fehler:

danach landen wir wieder auf der CMD.

Ich hab das hier gefunden aber ne wirkliche Lösung bietet es nicht an:

Grüße,

Josef

Problem solved by executing:

sfc /scannow

:smiley:

Josef