Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

calling dtexec.exe from powershell

369 views
Skip to first unread message

SW

unread,
Aug 14, 2007, 11:40:39 PM8/14/07
to
Hi...

Trying to script a call to dtexec.exe from Powershell.

I want to do something like: &'c:\windows\dtexec.exe'

But...the actual code to call dtexec in a command shell for instance
is:

dtexec /FILE "E:\SSIS\BBCSETL\CommonETL.dtsx" /MAXCONCURRENT " -1 " /
CHECKPOINTING OFF /REPORTING E /SET
"\Package.Variables[User::XMLQUERYB]";"2007-06-30T00:00:00" /SET
"\Package.Variables[User::XMLQUERYD]";"2007-05-01T00:00:00"

So, I need to use some set options, etc... I tried a couple of
different ways in powershell, but I kept getting random errors... How
does one call an exe from powershell and set switches, options, etc.?

Brandon Shell

unread,
Aug 15, 2007, 12:01:31 AM8/15/07
to
Just curious... can you try
$cmd = 'dtexec.exe /FILE "E:\SSIS\BBCSETL\CommonETL.dtsx" /MAXCONCURRENT
" -1 " /CHECKPOINTING OFF /REPORTING E
/SET"\Package.Variables[User::XMLQUERYB]";"2007-06-30T00:00:00"
/SET"\Package.Variables[User::XMLQUERYD]";"2007-05-01T00:00:00"'
invoke-expression $cmd

dtexec.exe needs to be in the path or you need to specify it.

"SW" <Steve.S...@gmail.com> wrote in message
news:1187149239....@i38g2000prf.googlegroups.com...

Bruce Payette [MSFT]

unread,
Aug 15, 2007, 2:05:13 AM8/15/07
to
The semicolon ';' is used to separate commands in PowerShell and the
backtick '`' is used to do line continuation. Try something like the
following:

dtexec /FILE E:\SSIS\BBCSETL\CommonETL.dtsx /MAXCONCURRENT -1 `
/CHECKPOINTING OFF /REPORTING E `


/SET '\Package.Variables[User::XMLQUERYB];2007-06-30T00:00:00' `

/SET '\Package.Variables[User::XMLQUERYD];2007-05-01T00:00:00'

and see if it works...

-bruce

--
Bruce Payette [MSFT]
Windows PowerShell Technical Lead
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.

Visit the Windows PowerShell Team blog at:
http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:
http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
My Book: http://manning.com/powershell


"SW" <Steve.S...@gmail.com> wrote in message
news:1187149239....@i38g2000prf.googlegroups.com...

SW

unread,
Aug 15, 2007, 10:30:25 AM8/15/07
to
On Aug 14, 11:05 pm, "Bruce Payette [MSFT]" <bruce...@microsoft.com>
wrote:

> The semicolon ';' is used to separate commands in PowerShell and the
> backtick '`' is used to do line continuation. Try something like the
> following:
>
> dtexec /FILE E:\SSIS\BBCSETL\CommonETL.dtsx /MAXCONCURRENT -1 `
> /CHECKPOINTING OFF /REPORTING E `
> /SET '\Package.Variables[User::XMLQUERYB];2007-06-30T00:00:00' `
> /SET '\Package.Variables[User::XMLQUERYD];2007-05-01T00:00:00'
>
> and see if it works...
>
> -bruce
>
> --
> Bruce Payette [MSFT]
> Windows PowerShell Technical Lead
> Microsoft Corporation
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> Visit the Windows PowerShell Team blog at:http://blogs.msdn.com/PowerShell
> Visit the Windows PowerShell ScriptCenter at:http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
> My Book:http://manning.com/powershell"SW" <Steve.S.Wal...@gmail.com> wrote in message

>
> news:1187149239....@i38g2000prf.googlegroups.com...
>
>
>
> > Hi...
>
> > Trying to script a call to dtexec.exe from Powershell.
>
> > I want to do something like: &'c:\windows\dtexec.exe'
>
> > But...the actual code to call dtexec in a command shell for instance
> > is:
>
> > dtexec /FILE "E:\SSIS\BBCSETL\CommonETL.dtsx" /MAXCONCURRENT " -1 " /
> > CHECKPOINTING OFF /REPORTING E /SET
> > "\Package.Variables[User::XMLQUERYB]";"2007-06-30T00:00:00" /SET
> > "\Package.Variables[User::XMLQUERYD]";"2007-05-01T00:00:00"
>
> > So, I need to use some set options, etc... I tried a couple of
> > different ways in powershell, but I kept getting random errors... How
> > does one call an exe from powershell and set switches, options, etc.?- Hide quoted text -
>
> - Show quoted text -

Tried that. It appears to not like the '/SET' commands.


You must provide a value expression on the right-hand side of the '/'
operator.
At line:1 char:163
+ dtexec /FILE "E:\SSIS\BBCSETL\BaseBsnCommonServicesETL
\BaseBsnCommonServicesETL\CommonETL.dtsx" /SET
"\Package.Variables[User::XMLQUERYB]";"2006-08-31T00:00:00" /S <<<< ET
"\Package.Variables[User::XMLQUERYD]";"2006-07-01T00:00:00"

SW

unread,
Aug 15, 2007, 10:31:13 AM8/15/07
to
On Aug 14, 9:01 pm, "Brandon Shell" <tshell.m...@mk.gmail.com> wrote:
> Just curious... can you try
> $cmd = 'dtexec.exe /FILE "E:\SSIS\BBCSETL\CommonETL.dtsx" /MAXCONCURRENT
> " -1 " /CHECKPOINTING OFF /REPORTING E
> /SET"\Package.Variables[User::XMLQUERYB]";"2007-06-30T00:00:00"
> /SET"\Package.Variables[User::XMLQUERYD]";"2007-05-01T00:00:00"'
> invoke-expression $cmd
>
> dtexec.exe needs to be in the path or you need to specify it.
>
> "SW" <Steve.S.Wal...@gmail.com> wrote in message

>
> news:1187149239....@i38g2000prf.googlegroups.com...
>
>
>
> > Hi...
>
> > Trying to script a call to dtexec.exe from Powershell.
>
> > I want to do something like: &'c:\windows\dtexec.exe'
>
> > But...the actual code to call dtexec in a command shell for instance
> > is:
>
> > dtexec /FILE "E:\SSIS\BBCSETL\CommonETL.dtsx" /MAXCONCURRENT " -1 " /
> > CHECKPOINTING OFF /REPORTING E /SET
> > "\Package.Variables[User::XMLQUERYB]";"2007-06-30T00:00:00" /SET
> > "\Package.Variables[User::XMLQUERYD]";"2007-05-01T00:00:00"
>
> > So, I need to use some set options, etc... I tried a couple of
> > different ways in powershell, but I kept getting random errors... How
> > does one call an exe from powershell and set switches, options, etc.?- Hide quoted text -
>
> - Show quoted text -

no workie.....

Invoke-Expression : You must provide a value expression on the right-


hand side of the '/' operator.

At line:1 char:18
+ invoke-expression <<<< $cmd

SW

unread,
Aug 15, 2007, 10:32:13 AM8/15/07
to
On Aug 14, 11:05 pm, "Bruce Payette [MSFT]" <bruce...@microsoft.com>
wrote:
> The semicolon ';' is used to separate commands in PowerShell and the
> backtick '`' is used to do line continuation. Try something like the
> following:
>
> dtexec /FILE E:\SSIS\BBCSETL\CommonETL.dtsx /MAXCONCURRENT -1 `
> /CHECKPOINTING OFF /REPORTING E `
> /SET '\Package.Variables[User::XMLQUERYB];2007-06-30T00:00:00' `
> /SET '\Package.Variables[User::XMLQUERYD];2007-05-01T00:00:00'
>
> and see if it works...
>
> -bruce
>
> --
> Bruce Payette [MSFT]
> Windows PowerShell Technical Lead
> Microsoft Corporation
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> Visit the Windows PowerShell Team blog at:http://blogs.msdn.com/PowerShell
> Visit the Windows PowerShell ScriptCenter at:http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
> My Book:http://manning.com/powershell"SW" <Steve.S.Wal...@gmail.com> wrote in message

>
> news:1187149239....@i38g2000prf.googlegroups.com...
>
>
>
> > Hi...
>
> > Trying to script a call to dtexec.exe from Powershell.
>
> > I want to do something like: &'c:\windows\dtexec.exe'
>
> > But...the actual code to call dtexec in a command shell for instance
> > is:
>
> > dtexec /FILE "E:\SSIS\BBCSETL\CommonETL.dtsx" /MAXCONCURRENT " -1 " /
> > CHECKPOINTING OFF /REPORTING E /SET
> > "\Package.Variables[User::XMLQUERYB]";"2007-06-30T00:00:00" /SET
> > "\Package.Variables[User::XMLQUERYD]";"2007-05-01T00:00:00"
>
> > So, I need to use some set options, etc... I tried a couple of
> > different ways in powershell, but I kept getting random errors... How
> > does one call an exe from powershell and set switches, options, etc.?- Hide quoted text -
>
> - Show quoted text -

I've looked (almost) everywhere online for some samples of calling
native commands (dtexec) with command line arguments, etc.... not much
luck.

Bruce Payette [MSFT]

unread,
Aug 15, 2007, 11:00:13 AM8/15/07
to
The semicolon is still not quoted in your example, so the phrase

"\Package.Variables[User::XMLQUERYB]";"2006-08-31T00:00:00"

is parsed as three tokens:

"\Package.Variables[User::XMLQUERYB]" ; "2006-08-31T00:00:00"

You need to put the quotes around the *entire* phrase:

"\Package.Variables[User::XMLQUERYB];2006-08-31T00:00:00"

Note that there are no quotes immediately before and after the semicolon.

-bruce

--
Bruce Payette [MSFT]
Windows PowerShell Technical Lead
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.

Visit the Windows PowerShell Team blog at:
http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:
http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
My Book: http://manning.com/powershell

"SW" <Steve.S...@gmail.com> wrote in message
news:1187188225.7...@g4g2000hsf.googlegroups.com...

SW

unread,
Aug 15, 2007, 11:23:22 AM8/15/07
to
On Aug 15, 8:00 am, "Bruce Payette [MSFT]" <bruce...@microsoft.com>
wrote:

> The semicolon is still not quoted in your example, so the phrase
>
> "\Package.Variables[User::XMLQUERYB]";"2006-08-31T00:00:00"
>
> is parsed as three tokens:
>
> "\Package.Variables[User::XMLQUERYB]" ; "2006-08-31T00:00:00"
>
> You need to put the quotes around the *entire* phrase:
>
> "\Package.Variables[User::XMLQUERYB];2006-08-31T00:00:00"
>
> Note that there are no quotes immediately before and after the semicolon.
>
> -bruce
>
> --
> Bruce Payette [MSFT]
> Windows PowerShell Technical Lead
> Microsoft Corporation
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> Visit the Windows PowerShell Team blog at:http://blogs.msdn.com/PowerShell
> Visit the Windows PowerShell ScriptCenter at:http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
> My Book:http://manning.com/powershell
>
> > "\Package.Variables[User::XMLQUERYD]";"2006-07-01T00:00:00"- Hide quoted text -

>
> - Show quoted text -

Thank you Bruce. That worked. Do you see any issue with me piping
the output of the dtexec call to a txt file?

By the way, can you digitally autograph my powershell book?


Keith Hill [MVP]

unread,
Aug 16, 2007, 1:54:27 PM8/16/07
to
"SW" <Steve.S...@gmail.com> wrote in message
news:1187149239....@i38g2000prf.googlegroups.com...

> Hi...
>
> Trying to script a call to dtexec.exe from Powershell.
>
> I want to do something like: &'c:\windows\dtexec.exe'
>
> But...the actual code to call dtexec in a command shell for instance
> is:
>
> dtexec /FILE "E:\SSIS\BBCSETL\CommonETL.dtsx" /MAXCONCURRENT " -1 " /
> CHECKPOINTING OFF /REPORTING E /SET
> "\Package.Variables[User::XMLQUERYB]";"2007-06-30T00:00:00" /SET
> "\Package.Variables[User::XMLQUERYD]";"2007-05-01T00:00:00"
>

As a tip of debugging future problems of this nature, PowerShell Community
Extensions has a tool for this called echoargs.exe that will show you how
the target EXE will get the params from PowerShell. Just substitute echoarg
for the exe e.g.

58# echoargs /FILE "E:\SSIS\BBCSETL\CommonETL.dtsx" /MAXCONCURRENT " -1 "

CHECKPOINTING OFF /REPORTING E /SET "\Packag
e.Variables[User::XMLQUERYB];2007-06-30T00:00:00" /SET
"\Package.Variables[User::XMLQUERYD];2007-05-01T00:00:00"

Arg 0 is </FILE>
Arg 1 is <E:\SSIS\BBCSETL\CommonETL.dtsx>
Arg 2 is </MAXCONCURRENT>
Arg 3 is < -1 >
Arg 4 is <CHECKPOINTING>
Arg 5 is <OFF>
Arg 6 is </REPORTING>
Arg 7 is <E>
Arg 8 is </SET>
Arg 9 is <\Package.Variables[User::XMLQUERYB];2007-06-30T00:00:00>
Arg 10 is </SET>
Arg 11 is <\Package.Variables[User::XMLQUERYD];2007-05-01T00:00:00>

Of course it won't help with problems like the statement separator ( ; )
since that blows up in PowerShell before any args are ever passed to
echoargs.

--
Keith
http://www.codeplex.com/powershellcx

0 new messages