Invoke-DevartExecuteScript

Synopsis

Automates the execution of scripts.

Description

This cmdlet executes a SQL script.

Syntax

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

Parameters

-Connection

Specifies the database connection to the server where the script is executed. You can provide one of the following options:

  • A DevartDatabaseConnectionInfo object, which contains detailed connection settings, produced by the New-DevartSqlDatabaseConnection cmdlet.
  • A connection string that defines how to connect to the database.
-Connection <object>
Property Default value
Required True
Position Named
Default value -
Accept pipeline input False
Accept wildcard characters False

-Input

Specifies an individual SQL or ZIP file with the script to run, or a folder with multiple SQL or ZIP files.

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

-Input <string>
Property Default value
Required True
Position Named
Default value -
Accept pipeline input False
Accept wildcard characters False

-Database

Specifies the database where the script will be executed. Any database names specified in the script will be ignored. This setting does not affect objects referenced by fully qualified names.

-Database <string>
Property Default value
Required False
Position Named
Default value -
Accept pipeline input False
Accept wildcard characters False

-Encoding

Specifies the encoding to be applied when opening and executing the script.

-Encoding <string>
Property Default value
Required False
Position Named
Default value -
Accept pipeline input False
Accept wildcard characters False

-ZipPassword

Specifies the password to access the protected archive.

-ZipPassword <string>
Property Default value
Required False
Position Named
Default value -
Accept pipeline input False
Accept wildcard characters False

-IgnoreError

Ignores errors during the script execution.

-IgnoreError <SwitchParameter>
Property Default value
Required False
Position Named
Default value False
Accept pipeline input False
Accept wildcard characters False

Common parameters

<CommonParameters>

This cmdlet supports these common parameters:

  • Verbose – Provides detailed output about the command operation.
  • Debug – Provides debugging information.
  • ErrorAction – Specifies how to respond to errors.
  • ErrorVariable – Stores error messages in a variable.
  • WarningAction – Specifies how to respond to warnings.
  • WarningVariable – Stores warning messages in a variable.
  • InformationAction – Specifies how informational messages are handled.
  • InformationVariable – Stores informational messages in a variable.
  • OutBuffer – Controls the number of objects buffered before output.
  • PipelineVariable – Stores the current pipeline object in a variable.
  • OutVariable – Stores output objects in a variable.

For more information, see About Common Parameters.

Output

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

System.Boolean returns:

  • true if the operation was successful.
  • false if the operation failed.

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