Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
517 changes: 263 additions & 254 deletions public/Expand-DbaDbLogFile.ps1

Large diffs are not rendered by default.

597 changes: 300 additions & 297 deletions public/Export-DbaUser.ps1

Large diffs are not rendered by default.

559 changes: 282 additions & 277 deletions public/Invoke-DbaAdvancedRestore.ps1

Large diffs are not rendered by default.

581 changes: 292 additions & 289 deletions public/Invoke-DbaDbDataGenerator.ps1

Large diffs are not rendered by default.

369 changes: 186 additions & 183 deletions public/Invoke-DbaDbPiiScan.ps1

Large diffs are not rendered by default.

347 changes: 174 additions & 173 deletions public/Invoke-DbaDiagnosticQuery.ps1

Large diffs are not rendered by default.

73 changes: 38 additions & 35 deletions public/Read-DbaBackupHeader.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -334,47 +334,50 @@ function Read-DbaBackupHeader {
Write-Message -Level Warning -Message "File $file does not exist or access denied. The SQL Server service account may not have access to the source directory."
}
}
#receive runspaces
while ($threads | Where-Object { $_.isRetrieved -eq $false }) {
$totalThreads = ($threads | Measure-Object).Count
$totalRetrievedThreads = ($threads | Where-Object { $_.isRetrieved -eq $true } | Measure-Object).Count
Write-Progress -Id 1 -Activity Updating -Status 'Progress' -CurrentOperation "Scanning Restore headers: $totalRetrievedThreads/$totalThreads" -PercentComplete ($totalRetrievedThreads / $totalThreads * 100)
foreach ($thread in ($threads | Where-Object { $_.isRetrieved -eq $false })) {
if ($thread.Handle.IsCompleted) {
$dataTable = $thread.thread.EndInvoke($thread.handle)
$thread.isRetrieved = $true
#Check if thread had any errors
if ($thread.thread.HadErrors) {
if ($thread.deviceType -eq 'FILE') {
Stop-Function -Message "Problem found with $($thread.file)." -Target $thread.file -ErrorRecord $thread.thread.Streams.Error -Continue
} else {
Stop-Function -Message "Unable to read $($thread.file), check credential $StorageCredential and network connectivity." -Target $thread.file -ErrorRecord $thread.thread.Streams.Error -Continue
try {
#receive runspaces
while ($threads | Where-Object { $_.isRetrieved -eq $false }) {
$totalThreads = ($threads | Measure-Object).Count
$totalRetrievedThreads = ($threads | Where-Object { $_.isRetrieved -eq $true } | Measure-Object).Count
Write-Progress -Id 1 -Activity Updating -Status 'Progress' -CurrentOperation "Scanning Restore headers: $totalRetrievedThreads/$totalThreads" -PercentComplete ($totalRetrievedThreads / $totalThreads * 100)
foreach ($thread in ($threads | Where-Object { $_.isRetrieved -eq $false })) {
if ($thread.Handle.IsCompleted) {
$dataTable = $thread.thread.EndInvoke($thread.handle)
$thread.isRetrieved = $true
#Check if thread had any errors
if ($thread.thread.HadErrors) {
if ($thread.deviceType -eq 'FILE') {
Stop-Function -Message "Problem found with $($thread.file)." -Target $thread.file -ErrorRecord $thread.thread.Streams.Error -Continue
} else {
Stop-Function -Message "Unable to read $($thread.file), check credential $StorageCredential and network connectivity." -Target $thread.file -ErrorRecord $thread.thread.Streams.Error -Continue
}
}
}
#Process the result of this thread

$dbVersion = $dataTable[0].DatabaseVersion
$SqlVersion = (Convert-DbVersionToSqlVersion $dbVersion)
foreach ($row in $dataTable) {
$row.SqlVersion = $SqlVersion
if ($row.BackupName -eq "*** INCOMPLETE ***") {
Stop-Function -Message "$($thread.file) appears to be from a new version of SQL Server than $SqlInstance, skipping" -Target $thread.file -Continue
#Process the result of this thread

$dbVersion = $dataTable[0].DatabaseVersion
$SqlVersion = (Convert-DbVersionToSqlVersion $dbVersion)
foreach ($row in $dataTable) {
$row.SqlVersion = $SqlVersion
if ($row.BackupName -eq "*** INCOMPLETE ***") {
Stop-Function -Message "$($thread.file) appears to be from a new version of SQL Server than $SqlInstance, skipping" -Target $thread.file -Continue
}
}
if ($Simple) {
$dataTable | Select-Object DatabaseName, BackupFinishDate, RecoveryModel, BackupSize, CompressedBackupSize, DatabaseCreationDate, UserName, ServerName, SqlVersion, BackupPath
} elseif ($FileList) {
$dataTable.filelist
} else {
$dataTable
}
}
if ($Simple) {
$dataTable | Select-Object DatabaseName, BackupFinishDate, RecoveryModel, BackupSize, CompressedBackupSize, DatabaseCreationDate, UserName, ServerName, SqlVersion, BackupPath
} elseif ($FileList) {
$dataTable.filelist
} else {
$dataTable
}

$thread.thread.Dispose()
$thread.thread.Dispose()
}
}
Start-Sleep -Milliseconds 500
}
Start-Sleep -Milliseconds 500
} finally {
Write-Progress -Id 1 -Activity Updating -Completed
}
Write-Progress -Id 1 -Activity Updating -Completed
#Close the runspace pool
$runspacePool.Close()
[System.Management.Automation.Runspaces.Runspace]::DefaultRunspace = $defaultrunspace
Expand Down
Loading
Loading