This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Param ( | |
$Server, | |
$Database, | |
$Path, | |
[switch]$IncludeData | |
) | |
# Prepare extraction properties string | |
$exportProperties = "/p:IgnorePermissions=True /p:IgnoreUserLoginMappings=True" # Ignore permissions definition | |
if ($IncludeData) { | |
$exportProperties += " /p:ExtractAllTableData=True" #Extract data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Cmdletbinding()] | |
Param ( | |
$SourceServer, | |
$TargetServer = $SourceServer, | |
$SourceDatabaseName, | |
$TargetDatabaseName, | |
$Path, | |
$PublishXml = '.\publish.xml', | |
[switch]$IncludeData | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" ?> | |
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<PropertyGroup> | |
<TargetConnectionString></TargetConnectionString> | |
<ProfileVersionNumber>1</ProfileVersionNumber> | |
<AllowIncompatiblePlatform>True</AllowIncompatiblePlatform> | |
<CreateNewDatabase>False</CreateNewDatabase> | |
<ExcludeObjectTypes>Permissions;RoleMembership</ExcludeObjectTypes> | |
<ExcludeLogins>True</ExcludeLogins> | |
<IgnorePermissions>True</IgnorePermissions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generating config files and using it later as a deployment template | |
New-DBOConfig -Configuration @{ DeploymentMethod = 'SingleTransaction'; SqlInstance = 'devInstance'; Database = 'MyDB' } | Export-DBOConfig '.\dev.json' | |
Get-DBOConfig -Path '.\dev.json' -Configuration @{ SqlInstance = 'prodInstance' } | Export-DBOConfig '.\prod.json' | |
Install-DBOPackage Deploy.zip -ConfigurationFile .\dev.json | |
Install-DBOPackage Deploy.zip -ConfigurationFile .\prod.json | |
# Extract current config from a package | |
Get-DBOPackage Deploy.zip | Export-DBOConfig '.\prod.json' | |
# Use existing configuration from a package and apply it to a different package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get current database from a PostgreSQL server | |
Invoke-DBOQuery -Type PostgreSQL -Server localhost:5432 -Database postgres -Query 'SELECT current_database()' -As SingleValue | |
# Run a query against MySQL database | |
Invoke-DBOQuery -Type MySQL -Server localhost -Database mysql -Query 'SELECT Name from Users' | |
# Run multiple files from a folder in a specific SQL Server database | |
Get-ChildItem .\Scripts | Invoke-DBOQuery -SqlInstance 'SqlServer1:1443' -Database MyDB | |
# Connect to an Oracle database interactively as SYSDBA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install a DBOps package to the MySQL server | |
Install-DBOPackage -Type MySQL -Server localhost -Database mydb -Path .\package.zip | |
# invoke a query against a remote PostgreSQL server | |
Invoke-DBOQuery -Type PostgreSQL -SqlInstance pgsql1:5432 -Database mydb -Query 'SELECT current_database();' | |
# change the default connection -Type (SQLServer) to PostgreSQL: | |
Set-DBODefaultSetting -Name rdbms.type -Value 'PostgreSQL' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Prompt { | |
try { | |
$history = Get-History -ErrorAction Ignore -Count 1 | |
if ($history) { | |
$ts = New-TimeSpan $history.StartExecutionTime $history.EndExecutionTime | |
switch ($ts) { | |
{$_.TotalMinutes -ge 1 } { | |
'[{0,5:f1} m]' -f $_.TotalMinutes | Write-Host -ForegroundColor Red -NoNewline | |
} | |
{$_.TotalMinutes -lt 1 -and $_.TotalSeconds -ge 1} { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Param ( | |
$SourceServer, | |
$TargetServer, | |
$SourceDatabase, | |
$TargetDatabase | |
) | |
$permissions = Export-DbaUser -SqlInstance $SourceServer -Database $SourceDatabase | |
Invoke-DbaQuery -SqlInstance $TargetServer -Database $TargetDatabase -Query $permissions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Param ( | |
$SourceServer, | |
$TargetServer, | |
$Login | |
) | |
$loginObject = Get-DbaLogin -SqlInstance $SourceServer -Login $Login | |
Copy-DbaLogin -Destination $TargetServer -Login $loginObject | |
foreach ($dbName in $login.EnumDatabaseMappings()) { | |
$db = Get-DbaDatabase -SqlInstance $SourceServer -Database $dbName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class testclass { | |
[string]$foo | |
testclass($input) { | |
$this.foo = $input | |
} | |
} | |
enum testenum { | |
foo | |
bar | |
} |
OlderNewer