I have an issue with passing a parameter with spaces into a powershell script. It seems to only work with the first part of the parameter string before the space
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True, ParameterSetName='firewallCommand',Position=0,HelpMessage="Input Firewall Index")]
[string]$fwName,
[Parameter(Mandatory=$True, ParameterSetName='firewallCommand',Position=1, HelpMessage="Input Firewall Command")]
[string]$fwCommand)
Within the script this will pass the parameters to the following command as such:
cprid_util -server $firewallIpAdd -verbose rexec -rcmd "$fwCommand"
On the command line if I run this it works:
.\fwcommand_run.ps1 -fwName firewall-name -fwCommand "ps"
If I run this it doesn't work at all:
.\fwcommand_run.ps1 -fwName firewall-name -fwCommand "ps -ef"
But if I invoke the command directly it does work:
cprid_util -server 10.1.128.4 -verbose rexec -rcmd ps -ef