romainsi/zabbix-VEEAM_B-R

PS script not work in Windows server 2008 R2 [Windows server 2012 working]

aurupong opened this issue · 1 comments

PS C:\Windows\system32> powershell.exe -NoProfile -ExecutionPolicy Bypass -File "C:\Program Files\Zabbix Agent\scripts\z
abbix_vbr_job.ps1" ExportXml
Unexpected token '.' in expression or statement.
At C:\Program Files\Zabbix Agent\scripts\zabbix_vbr_job.ps1:213 char:31

  • $item.replace('Failed', '0'). <<<<
    
    • CategoryInfo : ParserError: (.:String) [], ParentContainsErrorRecordException
    • FullyQualifiedErrorId : UnexpectedToken

PS C:\Windows\system32>

Hello, Please change the VeeamStatusReplace function on line 208 to 228 as follows :
Delete all carriage returns:

old :
function VeeamStatusReplace
{
[CmdletBinding()]
Param ([Parameter(ValueFromPipeline = $true)]
$item)
$item.replace('Failed', '0').
replace('Warning', '1').
replace('Success', '2').
replace('None', '2').
replace('idle', '3').
replace('InProgress', '5').
replace('Pending', '6').
replace('Pausing', '7').
replace('Postprocessing', '8').
replace('Resuming', '9').
replace('Starting', '10').
replace('Stopped', '11').
replace('Stopping', '12').
replace('WaitingRepository', '13').
replace('WaitingTape', '13').
replace('Working', '13')
}

new :

# Replace Function for Veeam Correlation
function VeeamStatusReplace
{
[CmdletBinding()]
Param ([Parameter(ValueFromPipeline = $true)]
$item)
$item.replace('Failed', '0').replace('Warning', '1').replace('Success', '2').replace('None', '2').replace('idle', '3').replace('InProgress', '5').replace('Pending', '6').replace('Pausing', '7').replace('Postprocessing', '8').replace('Resuming', '9').replace('Starting', '10').replace('Stopped', '11').replace('Stopping', '12').replace('WaitingRepository', '13').replace('WaitingTape', '13').replace('Working', '13') }