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
DatabaseName_yyyyMMddHHmm-x-of-y |
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
# This is based on the module state on 18th April 2020, it will have moved on since then! | |
Import-module dbaSecurityScan | |
# Create config and test against a new database | |
$config = New-DssConfig -SqlInstance server1\sql2017 -Database db1 | |
$config | ConvertTo-Json -Depth 5 | Out-File \\file\store\db1-SecurityConfig.json | |
# time passes and we want to check for security drift | |
# hydrate the config back into an object |
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
Copy-DbaDatabase -Source server1 -Destination MyNewMI.public.cus29s972e4513d6.database.windows.net,3342 -DestinationCredential $cred -SharedPath https://azblogdemo.blob.core.windows.net/sql -BackupRestore |
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
Import-Module dbatools | |
Import-Module Az | |
Connect-AzAccount | |
# Currently returns the wrong URL, use https://aka.ms/DeviceLogon instead | |
#Check you're in the correct subscription | |
Get-AzContext | |
#check existing Storage Accounts |
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 Convert-LSN { | |
<# | |
.SYNOPSIS | |
Converts Lsns betweent Hex and/or numeric formats | |
.DESCRIPTION | |
Function takes an LSN in either split Hexadecimal format () or numberic | |
It then returns both formats in an object |
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
$BackupHistory = Get-DbaBackupHistory -SqlInstance localhost\sqlexpress2016 -Database RestoreTimeStripe | |
$BackupHistory | ForEach {$_.FullName = $_.FullName | | |
ForEach { | |
($_ -replace 'c:\\dbatools\\RestoreTimeStripe\\stripe1','\\new\stripeA') -replace 'c:\\dbatools\\RestoreTimeStripe\\stripe2', '\\old\StripeB' | |
} | |
} |
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
Import-Module PoshRsJob | |
$servers = ('localhost\sqlexpress2016','localhost\developer2016') | |
$folders = ('\\localhost\dbatools$\RestoreTimeClean','\\localhost\dbatools$\RestoreTimeDiffDemo','\\localhost\dbatools$\restoretimeDiff') | |
$InputObject=@() | |
$Counter = 0 | |
ForEach ($folder in $folders){ | |
$InputObject += [PSCustomObject]@{ | |
ServerInstance = $servers[$Counter%($servers.count)] |
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
Import-Module poshrsjob | |
$folders = ('C:\dbatools\RestoreTimeClean','C:\dbatools\RestoreTimeDiffDemo','c:\dbatools\restoretimeDiff') | |
$job = $Folders | Start-RsJob -ModulesToImport dbatools -ScriptBlock { | |
param($Folder) | |
Get-DbaBackupInformation -SqlInstance localhost\SqlExpress2016 -Path $Folder | |
} | |
$job | Wait-RsJob -ShowProgress |
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
#First Scan: | |
Get-DbaBackupInformation -SqlInstance Server1\Instance1 -Path c:\backups -ExportPath c:\BackupInformation.xml | |
#Some time later: | |
$BackupInformation = Get-DbaBackupInformation -Import - Path c:\BackupInformation.xml | |
$LastScanTime = (Get-Item c:\BackupInformation.xml).LastWriteTime | |
$BackupInformation += Get-ChildItem c:\backups | Where-Object {$_.LastWriteTime -ge $LastScanTime} | Get-DbaBackupInformation -SqlInstance Server1\Instance1 | |
$BackupInformation | Export-CliXml -Path C:\BackupInformation.xml |
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
$BackupInformation = Get-DbaBackupInformation -sqlinstance localhost\sqlexpress2016 -Path C:\dbatools\RestoreTimeDiffDemo | |
$Environments = @('Dev','Test','Stage') | |
ForEach ($Environment in $Environments){ | |
$BackupInformation | Restore-DbaDatabase -sqlinstance localhost\sqlexpress2016 -DestinationFilePrefix $Environment -RestoredDatababaseNamePrefix ("$($Environment)_") -TrustDbBackupHistory | |
} |
NewerOlder