Is it possible to chain two PS Commands together when using Scripts?
For example the following script does a text replacement in the Zabbix Agent config file:
But I get the following error:
'Set-Content' is not recognized as an internal or external command, operable program or batch file'
So I figure it's an escape or issue piping commands? I've tried a few variations with brackets\parenthesis, but wanted to verify if this is even possible or if it's a syntax issue.
Thanks in advance,
*Update*
Got this working, example below. Hope it helps someone else!
For example the following script does a text replacement in the Zabbix Agent config file:
Code:
powershell.exe -Command {((Get-Content -path "C:\Program Files\Zabbix Agent\zabbix_agentd.conf" -Raw) -replace "# Timeout=3", "Timeout=30") | Set-Content -Path "C:\Program Files\Zabbix Agent\zabbix_agentd.conf"}
'Set-Content' is not recognized as an internal or external command, operable program or batch file'
So I figure it's an escape or issue piping commands? I've tried a few variations with brackets\parenthesis, but wanted to verify if this is even possible or if it's a syntax issue.
Thanks in advance,
*Update*
Got this working, example below. Hope it helps someone else!
Code:
powershell.exe -command "(gc -raw 'C:\Program Files\Zabbix Agent\zabbix_agentd.conf').replace('# Timeout=3', 'Timeout=30') | Set-Content 'C:\Program Files\Zabbix Agent\zabbix_agentd.conf'"