cdtech1980
MIS
I am trying to run the command below on multiple computers so I want to use invoke-command. It works fine in powershell and command line all by itself. But when I use invoke command and pass variables the nightmare happens.:
The problem I am having is trying to get this properly formatted in the invoke-command and passing variables using argument list. I can pass the variable correctly however the command is missing some single quote or double quotes. I just don't know where to put them.
Error:
A few things I notice
1) Slashes are now forward slashes, not sure if that makes difference.
2) my argument still contains [0]
This is driving me crazy. Thanks for any help. Do I need to run any ps-session commands before hand?
Code:
D:\Apache\bin\httpd.exe -f D:\apacheconfig\[URL unfurl="true"]www.foo.com\httpd.conf[/URL] -k install -n www.foo.com
The problem I am having is trying to get this properly formatted in the invoke-command and passing variables using argument list. I can pass the variable correctly however the command is missing some single quote or double quotes. I just don't know where to put them.
Code:
$Server = "server123"
$FQDN = "[URL unfurl="true"]www.foo.com"[/URL]
invoke-command -ComputerName $Server -ScriptBlock {& 'D:\Apache\bin\httpd.exe' -f D:\apacheconfig\$args[0]\httpd.conf -k install -n $args[0]} -ArgumentList $FQDN
Error:
Code:
httpd.exe: Wildcard patterns not allowed in Include D:/ApacheConfig/www.foo.com[0]/httpd.conf
+ CategoryInfo : NotSpecified: (httpd.exe: Wild...m[0].httpd.conf:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
+ PSComputerName : server123
A few things I notice
1) Slashes are now forward slashes, not sure if that makes difference.
2) my argument still contains [0]
This is driving me crazy. Thanks for any help. Do I need to run any ps-session commands before hand?