vMarkusK / Advanced-PRTG-Sensors

Collection of my Advanced PRTG Sensors
https://mycloudrevolution.com/
Apache License 2.0
69 stars 29 forks source link

Unable to load Veeam PowerShell Modules in PRTG #78

Closed vMarkusK closed 3 years ago

vMarkusK commented 3 years ago

Sorry we receive only the same generic message in PRTG:

XML: The returned XML does not match the expected schema. (code: PE233) -- JSON: The returned JSON does not match the expected structure (Invalid JSON.). (code: PE231)

The problem seems to be another. Running the latest script from github gives us the the following log message in the directory C:\ProgramData\Paessler\PRTG Network Monitor\Logs\sensors on the PRTG probe server:

C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\PRTG-VeeamBRStats.ps1 : The term 'Disconnect-VBRServer' 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 line:1 char:1

No Veeam Modules found, Fallback to SnapIn.

Running de script directly on the probe server with veem management console installed works fine. Any ideas?

Originally posted by @stoeffel2002 in https://github.com/vMarkusK/Advanced-PRTG-Sensors/issues/77#issuecomment-800136515

vMarkusK commented 3 years ago

Have a look at the comment from Johan:

https://mycloudrevolution.com/en/2020/01/27/prtg-veeam-sensor-retrospective/

It seems I’ve found the cause of the issue. For some reason PRTG won’t find the module when using: Import-module -name Veeam.Backup.Powershell as it claims it can’t find it. However, if I after “-name”, specify the complete path to the Veeam.Backup.Powershell.dll, the script is successfull. So the script is working fine and as intended, and the issue seems to be on our server and it’s ability to load the Module at times.

stoeffel2002 commented 3 years ago

Hi Markus, Thank you very much for that link. After using the full path "C:\Program Files\Veeam\Backup and Replication\Console\Veeam.Backup.PowerShell.dll" instead of veeam* on line 101 and line 122 and the full path "C:\Program Files\Veeam\Backup and Replication\Console\Veeam.Backup.PowerShell.dll" instead of Veeam.Backup.PowerShell on line 143, the script is runnig without any problems.

vMarkusK commented 3 years ago

@stoeffel2002 thanks for the confirmation.

Just to make sure, as an other user the original script works fine? Any idea what's the difference between the two user?

I have also created a Veeam forum thread regarding this behavior: https://forums.veeam.com/powershell-f26/failed-to-load-module-veeam-backup-powershell-t72872.html

vMarkusK commented 3 years ago

@stoeffel2002 might you please test this version: https://raw.githubusercontent.com/vMarkusK/Advanced-PRTG-Sensors/PSModulePath/Veeam/PRTG-VeeamBRStats.ps1

I have added a small hack to make sure PSModulePath includes Veeam Console.

stoeffel2002 commented 3 years ago

Hi Markus, Thank you for this new version. I've implemented it and it's running without any problem now. Before, I have tested the old script (without the full path) again and interestingly it worked also. Also after restarting the server with PRTG Probe and Veeam Console. I think this issue can be closed.

vMarkusK commented 3 years ago

Awsome. Thanks for your efforts.

I will wait for some additional feedback, just to make sure and the I will merge the PR.