Need Help on powershell script RRS feed

  • Question

  • Hi Expert,

    I have following code of Powershell where i am trying to sort lastest backup file of mysql database and then try to import this file 
    I am using the Powershell script for this according to script till the last i get desired o/p and then i copy this o/p and execute in seprate 
    cmd window it execute smooth but in power shell when i try to do the same thing it fails with following error please help me

    Error message

      C:\wamp\bin\mysql\mysql5.5.24\bin\mysql.exe --user=root --password=xxx testdest < "C:\mysqltemp\testsrc_2013-12-23_10-46-AM.sql" 
    cmd.exe : The system cannot find the file specified.
    At C:\Users\IBM_ADMIN\AppData\Local\Temp\8a7b4576-97b2-42aa-a0eb-42bb934833a6.ps1:19 char:4
    + cmd <<<<  /c " "$pathtomysqldump" --user=$param1 --password=$param2 $param3 < $param5 "
        + CategoryInfo          : NotSpecified: (The system cann...file specified.:String) [], RemoteException
        + FullyQualifiedErrorId : NativeCommandError

    Script is as following

    ##Select latest file created by Export of mysql dumper
    $a=(get-childitem C:\mysqltemp | sort LastWriteTime -Descending | Select-Object Name | select -first 1 -ExpandProperty Name)
    $pathtomysqldump = "C:\wamp\bin\mysql\mysql5.5.24\bin\mysql.exe"
    #Write-Host "Print variable A -------------"
    $a=$a.Replace(" ", "")
    #Write-Host "After Triming ---------------"
    #$p1="$param1 $param2 $param3 < $param5"
    # Invoke backup Command. /c forces the system to wait to do the backup
    Write-Host " "$pathtomysqldump" --user=$param1 --password=$param2 $param3 < $param5 "

    cmd /c " "$pathtomysqldump" --user=$param1 --password=$param2 $param3 < $param5 "

    Appericiate your time and valuable feedback

    Regards, Nirav Joshi

    • Edited by Nirav_Joshi Monday, December 23, 2013 7:08 AM
    Monday, December 23, 2013 7:02 AM