Link to home
Start Free TrialLog in
Avatar of tonelm54
tonelm54

asked on

String Concatenation¿ not in right order

Im trying to write a function, which looks quite simple:-
function backupMySQL([String]$dbHost, [String]$dbUsername, [String]$dbPassword, [String]$dbName, [String]$emailFrom, [String]$emailTo, [String]$emailSubject)
	{

    $strCmd = "& 'C:\Utils\Powershell\MySQL\mysqldump.exe' -h $dbHost -u $dbUsername -p$dbPassword $dbName"
    write-host $strCmd
	}

Open in new window


Im calling it as:-
backupMySQL("dbHost", "dbUsername", "dbPassword", "dbName", "emailFrom", "emailTo", "emailSubject")

Open in new window


While should output as:-
& 'C:\Utils\Powershell\MySQL\mysqldump.exe' -h dbHost -u dbUsername -pdbPassword dbName

However instead outputs as:-
& 'C:\Utils\Powershell\MySQL\mysqldump.exe' -h dbHost dbUsername dbPassword dbName emailFrom emailTo emailSubject -u  -p

What seems to be happening is all my variables Im passing through seem to be set as one instead of seperate, then its ignoring the others as null.

Any ideas what Im doing wrong with this please?

Thank you
ASKER CERTIFIED SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial