zbx-sadman / WSFC

Windows Server Failover Cluster (WSFC) metrics fetcher
GNU General Public License v3.0
24 stars 15 forks source link

PowerShell script execution fails for Windows Failover Cluster monitoring #4

Open brown257 opened 3 months ago

brown257 commented 3 months ago

Hello,

I am trying to install Windows Failover Cluster monitoring by carefully following each step indicated in this URL: https://github.com/zbx-sadman/WSFC. The problem is that when the powershell script is executed, the following error appears:

Import-Module : The specified module 'FailoverClusters' was not loaded because no valid module file was found in any module directory. At C:\Zabbix\scripts\wsfc.ps1:496 char:1

Get-Cluster : The term 'Get-Cluster' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Zabbix\scripts\wsfc.ps1:500 char:16

WARNING: No cluster(s) availabile

I changed the user running the service, removing the LocalSystem and placing a computer administrator user and the result is the same. I have also changed in the wsfc.ps1 the path where the FailoverClusters module is located and the same message still appears. If I place the module in the directory where the script is the message changes that it cannot load the DLLs it needs for the module load.

Please I require your help to implement this monitoring.

Thank you.

dreik commented 3 months ago

It really feels like that PowerShell on your server is a bit broken and/or you haven't installed required management modules. I.e. on Windows Server 2019 you'll have to install using following PowerShell command Install-WindowsFeature -name FailOver-Clustering -IncludeManagementTools Another possible cause is that your env var $env:PSModulePath was overwritten by some reason, make sure it contains following paths:

brown257 commented 3 months ago

Thank you for the prompt response.

The installation of the module had been executed as you indicate and I had also validated that the envs var were correct. I attach an image with the validations.

PS C:\Windows\system32> Install-WindowsFeature -name FailOver-Clustering -IncludeManagementTools
Success Restart Needed Exit Code Feature Result


True No NoChangeNeeded {}

PS C:\Windows\system32> $env:PSModulePath C:\Users\emp\Documents\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files\WindowsPowerShell\Modules;

Best regards