Invoke-DevartExecuteScript

Synopsis

Automates the execution of scripts.

Description

Use this cmdlet to execute a SQL script.

Syntax

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

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

Default value

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.

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

Required? true

Position? named

Default value

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

Default value

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

Default value

Accept pipeline input? false

Accept wildcard characters? false

-ZipPassword <string>

Specifies the password to protected archive with password.

Required? false

Position? named

Default value

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

<CommonParameters>

This cmdlet supports the following common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, InformationAction, InformationVariable, OutBuffer, PipelineVariable, and OutVariable. For more information, see About CommonParameters.

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

Want to Find out More?

Overview

Overview

Take a quick tour to learn all about the key benefits delivered by dbForge DevOps Automation for SQL Server.
Request a demo

Request a demo

If you consider employing the DevOps Automation for your business, request a demo to see it in action.
Ready to start using dbForge DevOps Automation for SQL Server?