Book Image

SQL Server 2014 with PowerShell v5 Cookbook

By : Donabel Santos
Book Image

SQL Server 2014 with PowerShell v5 Cookbook

By: Donabel Santos

Overview of this book

Table of Contents (21 chapters)
SQL Server 2014 with PowerShell v5 Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Downloading an SSIS package to a file


This recipe will download an SSIS package back to a .dtsx file.

Getting ready

Locate a package stored in the package store that you want to download to the filesystem. Note the path to this package.

How to do it...

These are the steps required to download an SSIS package:

  1. Open PowerShell ISE as an administrator.

  2. Add the ManagedDTS assembly as follows:

    #add ManagedDTS assembly
    Add-Type -AssemblyName "Microsoft.SqlServer.ManagedDTS, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
  3. Add the following script and run it:

    $server = "localhost"
    
    #create new app
    $app = New-Object "Microsoft.SqlServer.Dts.Runtime.Application"
    
    $timestamp = Get-Date -format "yyyy-MMM-dd-hhmmtt"
    $destinationFolder = "C:\SSIS\SSIS $($timestamp)"
    
    #If the path exists, will error silently and continue
    New-Item -ItemType Directory -Path $destinationFolder -ErrorAction SilentlyContinue
    
    $packageToDownload = "Customer Package"
    $packageParentPath = "\File System\QueryWorks"
    ...