Monday, February 1, 2016

Execute Process Task Powershell : blank space in the path

Execute Process Task Powershell : blank space in the path

    Question

  • Hello :-)
    I have a problem with my Execute Process Task in SSIS.
    I did this:
    Executable: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    Arguments: powershell -command "C:\Program Files\Microsoft SQL Server\100\DTS\Packages\SSIS-MY\myscript.ps1"
    Obviously, there is a problem due to space in the path because I got this error : "c:\program does not exit".
    So in CMD I tried this: 
    C:\Users\user>powershell -command C:\'Program Files'\'Microsoft SQL Server'\10
    0\DTS\Packages\SSIS-MY\myscript.ps1
    It works in CMD... but it does NOT work in SSIS.
    I tried this also: powershell -command "C:\'Program Files'\'Microsoft SQL Server'\10
    0\DTS\Packages\SSIS-MY\myscript.ps1"
    What should I do? :-)
    Thanks!!
    Tuesday, July 24, 2012 10:18 AM
    Avatar of MarDr
    10 Points

Answers

  • Hi,
    Please, replace the long path by its FAT 8.3 equivalent. Should be something similar to this
    powershell -command C:\Progra~1\Micros~3\100\DTS\Packages\SSIS-MY\myscript.ps1
    How to obtain FAT 8.3 representation of your path?
    Open a DOS prompt, then execute the following
    c:
    cd \
    Then execute dir /x
    It'll show both the long NTFS and the short FAT 8.3 folder names.
    Look for Program Files and take note of its short FAT 8.3 name, something like Progra~1 or similar.
    Then execute
    cd \Progra~1
    and run again dir /x to look for Microsoft SQL Server short representation (should something likeMicros~3 or Micros~2)
    Continue until you reached the file level.
    At the end, you'll have to whole FAT 8.3 representation of your file path.
    Use it on your script instead of c:\program files\microsoft sql server\...
    Bonne chance! Good luck!

    Sebastian Sajaroff Senior DBA Pharmacies Jean Coutu
    • Edited by Sebastian Sajaroff Tuesday, July 24, 2012 2:16 PM typo
    • Marked as answer by MarDr Tuesday, July 24, 2012 2:28 PM
    Tuesday, July 24, 2012 2:14 PM
    Avatar of Sebastian Sajaroff
    Longueuil (QC) - Canada
    6,805 Points

All replies

  • Pass the same command through an parameter..
    Tuesday, July 24, 2012 10:47 AM
    Avatar of King kalyan
    My own
    755 Points
  • build your arguments using expression and try validating the query. you might need to use escape characters for the path.
    MCTS, MCITP: BI Technical Consultant| Karabina, South Africa Blog: www.selectsifiso.net
    Tuesday, July 24, 2012 11:02 AM
    Avatar of Sifiso W. Ndlovu
    Karabina, Johannesburg, ...
    90 Points
  • Try replacing c:\program files\microsoft sql server\100\dts\packages\ssis-my\myscript.ps1 by its corresponding FAT 8.3 equivalent.

    Sebastian Sajaroff Senior DBA Pharmacies Jean Coutu
    Tuesday, July 24, 2012 12:16 PM
    Avatar of Sebastian Sajaroff
    Longueuil (QC) - Canada
    6,805 Points
  • OK. I tried to create an Argument in my task but I get this:
    TITRE : Microsoft Visual Studio
    ------------------------------

    Nonfatal errors occurred while saving the package:
    Error at Powershell - Project: L'expression contient le jeton non reconnu « powershell ». Si « powershell » est une variable, elle doit être exprimée sous la forme « @powershell ». Le jeton spécifié n'est pas valide. S'il représente un nom de variable, il doit comporter le symbole @ en préfixe.

    Error at Powershell - Project: Échec de l'analyse de l'expression « powershell -command C:\Program Files\Microsoft SQL Server\100\DTS\Packages\SSIS-MY\myscript.ps1" ». Code d'erreur retourné : 0xC00470A4. Impossible d'analyser l'expression. Elle contient peut-être des éléments non valides ou n'est peut-être pas bien formée. Cela peut aussi se produire en raison d'une erreur de mémoire insuffisante.

    Error at Powershell -Project: L'expression « powershell -command C:\Program Files\Microsoft SQL Server\100\DTS\Packages\SSIS-MY\myscript.ps1" » sur la propriété « Arguments » ne peut pas être évaluée. Modifiez l'expression pour qu'elle soit valide.
    Unfortunately it is in french. It is written "Echec reading expression "powershell -command" .
    I never used the "Expression" tab... maybe did I do something wrong?
    thanks :-)
    Tuesday, July 24, 2012 1:11 PM
    Avatar of MarDr
    10 Points
  • Error at Powershell - Project: L'expression contient le jeton non reconnu « powershell ». Si « powershell » est une variable, elle doit être exprimée sous la forme « @powershell ». Le jeton spécifié n'est pas valide. S'il représente un nom de variable, il doit comporter le symbole @ en préfixe.
    means
    The expression contains an unknown token "powershell". If "powershell" is a variable, then should be written as @powershell.
    Invalid token, should start with an @ symbol if representing a variable.
    Error at Powershell -Project: L'expression « powershell -command C:\Program Files\Microsoft SQL Server\100\DTS\Packages\SSIS-MY\myscript.ps1" » sur la propriété « Arguments » ne peut pas être évaluée. Modifiez l'expression pour qu'elle soit valide.
    means
    String «powershell ...» on Arguments property can't be evaluated. Please correct it.
    Finally, "echec" means Failure.

    Sebastian Sajaroff Senior DBA Pharmacies Jean Coutu
    Tuesday, July 24, 2012 1:40 PM
    Avatar of Sebastian Sajaroff
    Longueuil (QC) - Canada
    6,805 Points
  • Yeah Sebastian! :-)
    But in fact I am french so it was not a problem for me, I just wondered english people could not help me if they did not understand my error.
    It seems I can't write "powershell -command "path" "  in an Expression to create Arguments.. I do not understand how this tab works.
    Tuesday, July 24, 2012 2:02 PM
    Avatar of MarDr
    10 Points
  • Hi,
    Please, replace the long path by its FAT 8.3 equivalent. Should be something similar to this
    powershell -command C:\Progra~1\Micros~3\100\DTS\Packages\SSIS-MY\myscript.ps1
    How to obtain FAT 8.3 representation of your path?
    Open a DOS prompt, then execute the following
    c:
    cd \
    Then execute dir /x
    It'll show both the long NTFS and the short FAT 8.3 folder names.
    Look for Program Files and take note of its short FAT 8.3 name, something like Progra~1 or similar.
    Then execute
    cd \Progra~1
    and run again dir /x to look for Microsoft SQL Server short representation (should something likeMicros~3 or Micros~2)
    Continue until you reached the file level.
    At the end, you'll have to whole FAT 8.3 representation of your file path.
    Use it on your script instead of c:\program files\microsoft sql server\...
    Bonne chance! Good luck!

    Sebastian Sajaroff Senior DBA Pharmacies Jean Coutu
    • Edited by Sebastian Sajaroff Tuesday, July 24, 2012 2:16 PM typo
    • Marked as answer by MarDr Tuesday, July 24, 2012 2:28 PM
    Tuesday, July 24, 2012 2:14 PM
    Avatar of Sebastian Sajaroff
    Longueuil (QC) - Canada
    6,805 Points
  • yeah it works! I can run my Execute Process Task!
    It give me this path:
    powershell -command "C:\Progra~1\MI3EDC~1\100\DTS\Packages\SSIS-MY\myscript.ps1"
    Do you know if I move the SSIS package to another server it still will work? Or the short FAT 8.3 name change on each computers?

No comments:

Post a Comment