I have the following variable that contains other variables:
$jsontemplate = @"
{
"jsonrpc": "2.0",
"method": "trigger.update",
"params": {
"triggerid": "$($zabbixtriggerid)",
"status": 1
},
"id": "$($zabbixAuth.id)",
"auth": "$($zabbixAuth.auth)"
}
"@
$($xxx.yyy) format works fine if I run the script manually but I cannot use it because the program that runs the script uses tokens in $() format to insert strings into powershell scripts and will go crazy. Any other way to achieve the same effect? When I use just $xxx.yyy format, .yyy part gets ignored. It gets interpreted only when I use $() format.
You could use a format string to pass the values:
$jsontemplate = @"
{{
"jsonrpc": "2.0",
"method": "trigger.update",
"params": {{
"triggerid": "{0}",
"status": 1
}},
"id": "{1}",
"auth": "{2}"
}}
"@ -f $zabbixtriggerid, $zabbixAuth.id, $zabbixAuth.auth
Look at the last line where I format the string using the three variables.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With