Last active
March 24, 2024 14:36
-
-
Save Stuart-Moore/c9a31104759d66b7427311a6b6ae7a3b to your computer and use it in GitHub Desktop.
Parallel header scans on multiple Servers
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)] | |
Folder = $folder | |
} | |
$Counter++ | |
} | |
$InputObject | Start-RsJob -ModulesToImport dbatools -name {"test"} -ScriptBlock { | |
param($Input) | |
Get-DbaBackupInformation -SqlInstance $Input.ServerInstance -Path $Input.folder | |
} | |
$job | Wait-RsJob -ShowProgress | |
$BackupInformation = $job | Receive-RsJob | |
Get-RsJob | Remove-RSJob | |
$BackupInformation | Restore-DbaDatabase -SqlInstance Server1\Instance -TrustDbBackupHistory | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment