PowerShell Wrapper for Legacy Tools SqlCmd and SqlPackage
Executes SQLCMD
Invoke-LegacySqlPackage -Script <String> [-TargetUser <String>] [-TargetPassword <String>]
[-SourceUser <String>] [-SourcePassword <String>] [-AccessToken <String>] [-AzureSql]
[-InteractiveAuthentication] [-DropConstraintsNotInSource <Boolean>] [-DropDmlTriggersNotInSource <Boolean>]
[-DropExtendedPropertiesNotInSource <Boolean>] [-DropIndexesNotInSource <Boolean>]
[-DropObjectsNotInSource <Boolean>] [-DropPermissionsNotInSource <Boolean>]
[-DropRoleMembersNotInSource <Boolean>] [-DropStatisticsNotInSource <Boolean>]
[-ExcludeObjectTypes <String[]>] [-Timeout <Int32>] [-Variables <Hashtable>] [<CommonParameters>]
Invoke-LegacySqlPackage [-Publish] -DacPac <FileInfo> -TargetServerName <String> [-TargetUser <String>]
[-TargetPassword <String>] -TargetDatabaseName <String> [-SourceUser <String>] [-SourcePassword <String>]
[-AccessToken <String>] [-AzureSql] [-InteractiveAuthentication] [-DropConstraintsNotInSource <Boolean>]
[-DropDmlTriggersNotInSource <Boolean>] [-DropExtendedPropertiesNotInSource <Boolean>]
[-DropIndexesNotInSource <Boolean>] [-DropObjectsNotInSource <Boolean>]
[-DropPermissionsNotInSource <Boolean>] [-DropRoleMembersNotInSource <Boolean>]
[-DropStatisticsNotInSource <Boolean>] [-ExcludeObjectTypes <String[]>] [-Timeout <Int32>]
[-Variables <Hashtable>] [-Force] [<CommonParameters>]
Invoke-LegacySqlPackage [-Extract] [-DacPac <FileInfo>] [-TargetUser <String>] [-TargetPassword <String>]
-SourceServerName <String> [-SourceUser <String>] [-SourcePassword <String>] [-AccessToken <String>]
-SourceDatabaseName <String> [-AzureSql] [-InteractiveAuthentication] [-DropConstraintsNotInSource <Boolean>]
[-DropDmlTriggersNotInSource <Boolean>] [-DropExtendedPropertiesNotInSource <Boolean>]
[-DropIndexesNotInSource <Boolean>] [-DropObjectsNotInSource <Boolean>]
[-DropPermissionsNotInSource <Boolean>] [-DropRoleMembersNotInSource <Boolean>]
[-DropStatisticsNotInSource <Boolean>] [-Timeout <Int32>] [-Variables <Hashtable>] [<CommonParameters>]
Wrapper tp the commandline tool SQLPACKAGE. It provides parameter validation, output and error handling.
PS C:\>
Flag if a install script should be created.
Type: String
Parameter Sets: Script
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Flag if a database should be published.
Type: SwitchParameter
Parameter Sets: Publish
Aliases:
Required: True
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Type: SwitchParameter
Parameter Sets: Extract
Aliases:
Required: True
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Path to the dacpac file. [ValidateScript({ $_.Exists })]
Type: FileInfo
Parameter Sets: Publish
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Type: FileInfo
Parameter Sets: Extract
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Name of the SQL Server Instance to publish the dacpac to.
Type: String
Parameter Sets: Publish
Aliases: ServerInstance, DataSource
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Username for the login.
Type: String
Parameter Sets: (All)
Aliases: Username
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Password for the login.
Type: String
Parameter Sets: (All)
Aliases: Password
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Name of the SQL database to publish the dacpac to.
Type: String
Parameter Sets: Publish
Aliases: DatabaseName, Database
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Name of the SQL Server Instance to publish the dacpac to.
Type: String
Parameter Sets: Extract
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Username for the login.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Password for the login.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
AccessToken for the login
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Name of the SQL database to publish the dacpac to.
Type: String
Parameter Sets: Extract
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Flag if the SQL Server is a Azure SQL Server.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Flag if interactive authentication is used.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Flag if surplus contraints should be dropped.
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Flag if surplus triggers should be dropped.
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Flag if surplus properties should be dropped.
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Flag if surplus indices should be dropped.
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Flag if surplus objects should be dropped.
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Flag if surplus permissions should be dropped.
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Flag if surplus role members should be dropped.
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Flag if surplus statistics should be dropped.
Type: Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
A semicolon-delimited list of object types that should be ignored during deployment
Type: String[]
Parameter Sets: Script, Publish
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Timeout is seconds for the execution.
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
Values for the variables used in the dacpac.
Type: Hashtable
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: @{}
Accept pipeline input: False
Accept wildcard characters: False
Force the action and accept the risk of data loss.
Type: SwitchParameter
Parameter Sets: Publish
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Check https://github.com/abbgrade/PsDac and https://github.com/abbgrade/PsSmo if one of them already supports your use case. They provide better PowerShell integration.
https://docs.microsoft.com/de-de/sql/tools/sqlpackage?view=sql-server-ver15