Skip to content

Instantly share code, notes, and snippets.

@Stuart-Moore
Last active March 24, 2024 14:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Stuart-Moore/c9a31104759d66b7427311a6b6ae7a3b to your computer and use it in GitHub Desktop.
Save Stuart-Moore/c9a31104759d66b7427311a6b6ae7a3b to your computer and use it in GitHub Desktop.
Parallel header scans on multiple Servers
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