I've a simple command that I need to execute via PowerShell on remote machine.
E:\Programs\GMM\bin\GMMFailoverTool.exe -mssql="Server=SomeServer;Database=GMM01" list
The problem I'm having is executing it properly with PowerShell even without trying to do this via Invoke-Command.
$binary = "E:\Programs\GMM\bin\GMMFailoverTool.exe"
$command = "-mssql=`"Server=SomeServer;Database=gmm01`" list"
Write-Host BINARY: $binary -ForegroundColor Yellow
write-Host ARGS: $command -ForegroundColor Yellow
Write-Host FullCommand: $binary $command -ForegroundColor Yellow
& $binary $command
Output:
BINARY: E:\Programs\GMM\bin\GMMFailoverTool.exe
ARGS: -mssql="Server=SomeServer;Database=gmm01" list
FullCommand: E:\Programs\GMM\bin\GMMFailoverTool.exe -mssql="Server=SomeServer;Database=gmm01" list
And the return of the command is like it didn't get any parameters at all (or those were incorrect).
The question is how to properly pass those arguments where $command is already defined as it should? If I do it by hand without having it all in variables it works…
& "E:\Programs\GMM\bin\GMMFailoverTool.exe" -mssql="Server=SomeServer;Database=gmm01" list