Automates the execution of scripts.
Use this cmdlet to execute a SQL script.
Invoke-DevartExecuteScript -Connection <object> -Input <string> [-Database <string>] [-Encoding <string>] [-IgnoreError <SwitchParameter>] [-ZipPassword <string>] [<CommonParameters>]
-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.
System.Boolean (returns true on success and false otherwise)
---------- 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