Run DTEXEC from Powershell - convert from batch file

  • I have the following dtexec command that works fine in a cmd batch file:

    dtexec /f %DTSPackagesDir%"\%SSISJob%" /Decrypt %DTSPassword% /CONN cm_sql_USTG;%cm_sql_USTG% /Reporting E /Set \Package.Variables[User::strDestinationFolderForFlatFile].Value;%TargetDir%\ /Set \Package.Variables[User::strExtractType].Value;%ExtractType% /Set \Package.Variables[User::strDayKey].Value;%ProcDate%

    I tried converting it for Powershell and ended up with this:

    dtexec /f "$cfgDTSPackagesDir\$DTSPackageName /Decrypt $cfgDTSPassword /CONN cm_sql_USTG;$cm_sql_USTG /Reporting E /Set \Package.Variables[User::strDestinationFolderForFlatFile].Value;$TargetDir\ /Set \Package.Variables[User::strExtractType].Value;$ExtractType /Set \Package.Variables[User::strDayKey].Value;$DayKey"

    The connection string is:

    Set-Variable -name cm_sql_ustg "Data Source=$cfgDBServer;Initial Catalog=$cfgDBName;Provider=SQLNCLI10.1;Integrated Security=SSPI;Auto Translate=False;Application Name=$AppName"; Write-Output "Connection String cm_sql_ustg: $cm_sql_ustg"

    I am either getting that the "system cannot find the file specified" and I know it is there, or if I make some changes, it stops on the connection string, not recognizing "Source" (as part of the "Data Source ...." string.

    Thanks for any help.

  • dcwilson2009 (6/12/2015)


    I tried converting it for Powershell ...

    If the batch file was working, then I have to ask... WHY?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • I have seen PowerShell get confused when calling external commands with lots of parameters. In that case you might have to call start-process with dtexec and specify each of the arguments in the -argumentlist parameter

    Start-Process

    Joie Andrew
    "Since 1982"

  • Sorry. I have been unavailable. Did you resolve this?

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply