Invoke-DevartExecuteScript

Synopsis

Automates executing the scripts.

Syntax:

Invoke-DevartExecuteScript -Connection <object> -Input <string> [-Database <string>] [-Encoding <string>] [-IgnoreError <SwitchParameter>] [-ZipPassword <string>] [<CommonParameters>]

Description:

If -Input is a folder, the scripts are executed in alphabetical order (subfolders are ignored).

Parameters:

-Connection <object>

Specifies a connection to the server where to execute the script.

This can be:

  • an instance of a DevartDatabaseConnectionInfo object produced by the New-DevartSqlDatabaseConnection cmdlet.

  • a database connection string.

Required? true

Position? named

Accept pipeline input? false

Accept wildcard characters? false

-Input <string>

This switch is used to specify an SQL or ZIP file with the script to execute or a folder with SQL or ZIP files.

Required? true

Position? named

Accept pipeline input? false

Accept wildcard characters? false

-Database <string>

Specifies a database to execute the script to.

Databases specified in the script before will be ignored.

It does not affect the objects specified with fully qualified names.

Required? false

Position? named

Accept pipeline input? false

Accept wildcard characters? false

-Encoding <string>

Specifies the encoding which should be applied to open and execute the script.

Usage: /encoding:<codepage|encoding name>

Required? false

Position? named

Accept pipeline input? false

Accept wildcard characters? false

-ZipPassword <string>

Specifies the password to protected archive with password.

Required? false

Position? named

Accept pipeline input? false

Accept wildcard characters? false

-IgnoreError <SwitchParameter>

Use this parameter to continue executing scripts in the folder despite errors.

Required? false

Position? named

Default value false

Accept pipeline input? false

Accept wildcard characters? false

Outputs:

System.Boolean (returns true on success and false otherwise)

Examples:

---------- EXAMPLE 1 ----------
Invoke-DevartExecuteScript -Connection $connection -Database AdventureWorks -Input script.sql
---------- EXAMPLE 2 ----------
Invoke-DevartExecuteScript -Connection $connection -Database AdventureWorks -Input script.zip -ZipPassword ***
---------- EXAMPLE 3 ----------
Invoke-DevartExecuteScript -Connection $connection -Database AdventureWorks -Input D:\ScriptFolder -IgnoreError