Functions/PoShMon.SharePoint/Test-DatabaseHealth.ps1
Function Test-DatabaseHealth { [CmdletBinding()] param ( [System.Management.Automation.Runspaces.PSSession]$RemoteSession ) $stopWatch = [System.Diagnostics.Stopwatch]::StartNew() $mainOutput = Get-InitialOutput -SectionHeader "Database Status" -OutputHeaders ([ordered]@{ 'DatabaseName' = 'Database Name'; 'Size' = 'Size (GB)'; 'NeedsUpgrade' = 'Needs Upgrade?' }) $spDatabases = Invoke-Command -Session $RemoteSession -ScriptBlock { return Get-SPDatabase | Sort DiskSizeRequired -Descending } foreach ($spDatabase in $spDatabases) { $highlight = @() if ($spDatabase.NeedsUpgrade) { $mainOutput.NoIssuesFound = $false Write-Verbose ($spDatabase.DisplayName + " (" + $spDatabase.ApplicationName + ") is listed as Needing Upgrade") $highlight += 'NeedsUpgrade' } $mainOutput.OutputValues += @{ 'DatabaseName' = $spDatabase.DisplayName; 'NeedsUpgrade' = &{if($spDatabase.NeedsUpgrade) {"Yes"} else {"No"}}; 'Size' = ($spDatabase.DiskSizeRequired/1GB).ToString(".00"); 'Highlight' = $highlight } } $stopWatch.Stop() $mainOutput.ElapsedTime = $stopWatch.Elapsed return $mainOutput } <# $output = Test-DatabaseHealth $remoteSession -Verbose #> |