[string]$pathToExe = "C:\MySQL\MySQL Server 5.1\bin\mysqldump.exe";
[string]$user = "myUser";
[string]$password = "myPass";
[string]$dbName = "myDB";
[Array]$arguments = "-u", $user, "--password=$password", $dbName;
& $pathToExe $arguments | Out-File -FileName "out.sql";
So there you have it. That's how to run an executable with spaces and arguments from PowerShell.
While this article from PowerShell.com didn't answer my questions, I thought it was pretty useful and relevent:
http://powershell.com/cs/blogs/ebook/archive/2009/03/30/chapter-12-command-discovery-and-scriptblocks.aspx
No comments:
Post a Comment