Powershell dtutil

My Learning: Log in Learning Report [Log in]


Remove Ads or Log in
Remove Ads or Log in
+0  |  -0
Powershell Dtutil (Dtutil.exe) – When I first tried PowerShell with Dtutil command line tool I had an issue to run the command. The problem was semicolon ; which is a special character in Powershell. For those having similar issue see below how you can run dtutil command from PowerShell:

Here is a simple copy file example:

dtutil /FILE ".\SourceFileFromTheSameFolder.dtsx" /COPY FILE';C:\Program Files\Microsoft SQL Server\100\DTS\Packages\PackageFinalDestination.dtsx' /Quiet

In the above command I just move file from folder where I have my PowerShell script into FileSystem SSIS default folder.
Notice that I put apostrophe ‘ before semicolon ; if I didn’t do that it would give the following error:
Unexpected token 'Quiet' in expression or statement.
And if I removed /Quiet it would give next error:
Argument "FILE" for option "copy" is not valid.

Below is code that I am still working on and additionally get dynamically DTSPath from registry which I hope will be reliable way to do it. Captures result in variable to avoid ugly message and then output the result and pauses.

$DTSPath = (get-itemproperty -path "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\100\SSIS\Setup\DTSPath").'(default)'

$result = dtutil /FILE ".\SourcePackage.dtsx" /COPY FILE';'$DTSPath'Packages\Destination.dtsx' /Quiet

if ($LASTEXITCODE -eq 0) {Write-Host "Package Deployment result (ERS CSV Load)…ok"}
elseif ($LASTEXITCODE -eq 1) {Write-Host "Package Deployment result (ERS CSV Load)…*** ERROR *** The utility failed. Error code 1"}
elseif ($LASTEXITCODE -eq 4) {Write-Host "Package Deployment result (ERS CSV Load)…*** ERROR *** The utility cannot locate the requested package. Error code 4"}
elseif ($LASTEXITCODE -gt 5) {Write-Host "Package Deployment result (ERS CSV Load)…*** ERROR *** The utility cannot load the requested package. Error code 5"}
elseif ($LASTEXITCODE -gt 6) {Write-Host "Package Deployment result (ERS CSV Load)…*** ERROR *** The utility cannot resolve the command line because it contains either syntactic or semantic errors. Error code 6"}
else {"Package Deployment result (ERS CSV Load)…*** ERROR *** Unidentified Error."}

Write-Host "Press any key to continue …"
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

Powershell dtutil

See also: DTUTIL - Microsoft documentation

Hope that helps
Emil

Remove Ads or Log in

We need you!

By becoming a proud member we can:
  • Switch off annoying ads
  • Create more articles and videos
  • Develop more useful features supporting your learning
  • Provide FREE webinars (for members)
  • Feel our hard work since 2011 is appreciated
Become a proud member and get exclusive features.

If 2% of our 64,943 visitors (Last 30 days) become a proud member than we can quit our jobs and work full time on this website. We started membership in May 2014 and so far 0.07% of our visitors are members and we would like to say THANK YOU to those who become a proud member and support our efforts.

Thanks to members:
  • Education is for FREE and we create more FREE articles and videos
  • We provide new features (members) that can speed up learning.
  • 53% of our page views (82,000 each month) do not have page ads.
  • We switched video ads from 14% of our videos (50 out of 345).
We have invested 4 years of our time in this website and we estimate it will take about 5 years before we can quit our jobs and dedicate all our time to develop considerably our website which should help to truly achieve our vision of free education for everyone; all thanks to support of our members only. Become a proud member

Visitor Voting

Did you know we (Katie & Emil) immigrated to UK in 2005 without knowing English, having any IT skills (or degree) and we set up a website in 2008 to learn by teaching?
Visitor Voting: Yes +13  |  No -6
Add comment (no email required).



Add Comment
No data was returned.


Are you a member?

If yes than please log in

Learning Map is for members with Bronze, Silver and Gold Membership.
For more information visit membership options.


Close this window , log in or learn more about membership benefits
  Become a Proud Member