Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Problems running a command remotely with parameters

$
0
0

Hi

I am attempting to run a command with parameters remotely but have spent days trying to find the right format for the parameters. I have used PowerShell for a while but am new to remoting. The command that I am trying to execute is  MySQL.exe –uFred –ppassword  –e “create database IP_Addresslist”;  where –u is the user, -p is the password and –e specifies the mysql command to run (in quotes).

I have tried many combinations including the one shown below but with no success.

$MySQLuser="-uFred "

$MySQLPW="-ppassword "

$MySQLcmd="-e `"create database IP_Addresslist`";"

 

invoke-Command -ComputerName SERVER1 -ScriptBlock {"\\SERVER1\c$\Program Files\MySQL\MySQL Server 5.6\bin\mysql.exe " $using:MySQLuser,$using:MySQLPW,$using:MySQLcmd }

This particular command gives the following error message.

At E:\Programming\Powershell\Scripts\remote programming exercise.ps1:14 char:119

+ ... Files\MySQL\MySQL Server 5.6\bin\mysql.exe " $using:MySQLuser,$using: ...

+ ~~~~~~~~~~~~~~~~

Unexpected token '$using:MySQLuser' in expression or statement.

+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException

+ FullyQualifiedErrorId : UnexpectedToken

Does anybody have an idea of where I’m going wrong, or is there an easier way of achieving this? Thanks

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles