I'm currently in the process of creating a new automated PowerShell script to update our RMM agent software on machines. The PS script is designed as a fall back to the in-built automation.
When creating the parameters of .exe file, it works on a new PowerShell line but fails when invoked through the script.
Running the command as an explicit command from PowerShell works fine. Does not work when invoking with two strings.
My PS Parameters:
param (
[string] $cust,
[string] $name,
[switch] $client,
[switch] $server,
[switch] $noprobe,
[switch] $custom
)
Important Variables:
$NETLOGON = $env:LOGONSERVER
$agentInstall = $NETLOGON+"\NETLOGON\Agent\WindowsAgentSetup.exe"
The command that calls the install:
$agentParams = "/s --% /v"CUSTOMERID=$cust CUSTOMERNAME=$name SERVERPROTOCOL=HTTPS SERVERADDRESS=domain.com SERVERPORT=443""
& $agentInstall $agentParams
It does run the EXE, but nothing happens (like the syntax was wrong). No logs or any output as to why it fails.
If I run the command as the following:
\\SERVER\NETLOGON\Agent\WindowsAgentSetup.exe /s --% /v"CUSTOMERID=100 CUSTOMERNAME=\"Customer One\" SERVERPROTOCOL=HTTPS SERVERADDRESS=domain.com SERVERPORT=443"
No problem at all.
Any advice would be appreciated, but I'm guessing it's a syntax issue.
The --% is required to parse it through correctly.