vMarkusK / Advanced-PRTG-Sensors

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

VeeamBRStats.ps1 - Connection Error #43

Closed vMarkusK closed 4 years ago

vMarkusK commented 4 years ago

Hello, iam stuck in the connection. Changed localhost to our server: param( [Parameter(Position=0, Mandatory=$false)] [string] $BRHost = "BKUP01",

With PSx64.exe i get the wanted XML output. But the Sensor Logs comes up with: Failed to connect to Veeam BR Host even when it is hardcoded in the powershell script. So i checked the user, its running with a credential which is approved to connect. Means i logged in on the same remote host the PRTG probe is installed and run the script with PSx64 which gives me the XML output.

Error Output: `C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\VeeamBRStats.ps1 : Failed to connect to Veeam BR Host At line:1 char:1

1 Failed to connect to Veeam BR Host

`

` OS: WS 2016 PSx64: 18.1.1.6

0: Name Value


PSVersion 5.1.14393.3053 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.14393.3053 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1`

Also i tried with Parameters in PRTG as: -f="FileName.ps1 -p="BKUP01" and -f="FileName.ps1" -p="-BRHost BKUP01"

Any ideas here?

Originally posted by @eulisan in https://github.com/mycloudrevolution/Advanced-PRTG-Sensors/issues/42#issuecomment-561172604

vMarkusK commented 4 years ago

Hi @eulisan ,

I have split this request into a dedicated issue.

Have you tried to Connect via VBR Console from the server where the PowerShell script is executed?

eulisan commented 4 years ago

First of all. Thank you for the quick reply. Yes i can use the VBR GUI Console with the remote VBR Server and the same user used by PRTG. In Addition iam also able to connect via Powershell and the Connect-VBRServer cmdlet.

revilo55 commented 4 years ago

Hi Both,

I am too getting the same error:

C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE\PRTG-VeeamBRStats.ps1 : Failed to connect to Veeam BR Host At line:1 char:1

C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE\PRTG-VeeamBRStats.ps1 : at , C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE\PRTG-VeeamBRStats.ps1: line 202 at , : line 1 At line:1 char:1

1 Failed to connect to Veeam BR Host

Any help will be much appreciated.

Thanks

vMarkusK commented 4 years ago

@revilo55 Have you tried to Connect via VBR Console from the server where the PowerShell script is executed?

vMarkusK commented 4 years ago

@eulisan and @revilo55 Have you tried to execute the script without PSx64.exe (same user and server) ?

revilo55 commented 4 years ago

@revilo55 Have you tried to Connect via VBR Console from the server where the PowerShell script is executed?

Yes, I'm able get a response from veeam.

vMarkusK commented 4 years ago

@revilo55 and the script execution without PSx64?

revilo55 commented 4 years ago

I ran ./PRTG-VeeamBRStats.ps1 -BRhost "fqdn of host".

Using the original script.

That was run straight from powershell as admin, which gave a result.

eulisan commented 4 years ago

Got the same results as revilo. Even when running PSx64 via PS Console without PRTG got the results. Just when the script is executed via PRTG it returns "Failed to connect to Veeam BRHost". Confusing.

Legoracers commented 4 years ago

When I run the script in Powershell 64 bit it runs fine. When I run the script in powershell x86 with PSx64 it gives an error "Failed to connect to Veeam BR Host". The remote console connects without issues.

Veeam version 9.5.4.2866 (community edition) Windows 1909

vMarkusK commented 4 years ago

Got the same results as revilo. Even when running PSx64 via PS Console without PRTG got the results. Just when the script is executed via PRTG it returns "Failed to connect to Veeam BRHost". Confusing.

@eulisan Do you pass the Veeam Hostname as a parameter?

vMarkusK commented 4 years ago

When I run the script in Powershell 64 bit it runs fine. When I run the script in powershell x86 with PSx64 it gives an error "Failed to connect to Veeam BR Host". The remote console connects without issues.

Veeam version 9.5.4.2866 (community edition) Windows 1909

@Legoracers Do you pass the Veeam Hostname as a parameter?

vMarkusK commented 4 years ago

I have added additional Debug Output and Error Details during connection.

Might you please run a few tests with this version of the Script: https://github.com/mycloudrevolution/Advanced-PRTG-Sensors/blob/ConnectionDetails/Veeam/PRTG-VeeamBRStats.ps1

PS 64Bit: ./PRTG-VeeamBRStats.ps1 -Debug

PS 64Bit: ./PRTG-VeeamBRStats.ps1

PS 32Bit: ./PRTG-VeeamBRStats.ps1 -Debug

PS 32Bit: ./PRTG-VeeamBRStats.ps1

CMD: PSx64.exe -f="PRTG-VeeamBRStats.ps1"

Legoracers commented 4 years ago

When I run the script in Powershell 64 bit it runs fine. When I run the script in powershell x86 with PSx64 it gives an error "Failed to connect to Veeam BR Host". The remote console connects without issues. Veeam version 9.5.4.2866 (community edition) Windows 1909

@Legoracers Do you pass the Veeam Hostname as a parameter?

Yes, I tried the IP address and the hostname. Both of them don't work with the PSx64 but do in 64 bit powershell.

In 32 bit the Veeam PS snapin is not available.

These are the error codes when I try PSx64: Microsoft.PowerShell.Commands.WriteErrorException,PRTG-VeeamBRStats.ps1

C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\PRTG-VeeamBRStats.ps1 : 
at <ScriptBlock>, C:\ProgramFiles (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\PRTG- 
VeeamBRStats.ps1: line 203
at <ScriptBlock>, <No file>: line 1
At line:1 char:1
+ &'C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\P ...
+ 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,PRTGVeeamBRStats.ps1
vMarkusK commented 4 years ago

I assume there is an issue parsing the parameter from PSx64 to the Script itself.

Might you please replace the default value of the BRHost ("localhost") in the script with your Veeam B&R Server FQDN and run the script via PSx64 without any additional parameter.

You need to modify line 47: [string] $BRHost = "localhost",

Legoracers commented 4 years ago

Thanks for your reply! The solution metioned works!

vMarkusK commented 4 years ago

@eulisan have you also been able to verify the provided solution?

Legoracers commented 4 years ago

It read the states and triggers the sensor accordingly.