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
tonelm54Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rainer JeschorCommented:
Hi,
your calling code is wrong, instead of putting everything in parathensis and separating by "," you simply have to call it like this (no parathensis and space as parameter separator):
backupMySQL "dbHost" "dbUsername" "dbPassword" "dbName" "emailFrom" "emailTo" "emailSubject"

Open in new window


With your call, all values are treated as the first parameter.

HTH
Rainer
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.