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

Executing an SSIS package stored in a package store or filesystem


In this recipe, we will execute an SSIS package using PowerShell.

Getting ready

In this recipe, we will execute the Customer Package, which is saved in the package store, and we will also execute the C:\SSIS\SamplePackage.dtsx file directly from the filesystem.

Alternatively, you can locate an available SSIS package in your system that you want to execute instead. Identify whether this package is stored in the filesystem or in the SSIS package store.

How to do it...

Let's explore the code required to execute an SSIS package programmatically using PowerShell:

  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 we'll use for SSIS
    $app = New-Object "Microsoft.SqlServer.Dts.Runtime.Application...