-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-Inventory.ps1
More file actions
28 lines (23 loc) · 1012 Bytes
/
Get-Inventory.ps1
File metadata and controls
28 lines (23 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Get all servers from your CMS (assuming you have them registered)
# Or just a list for now
$ServerList = Get-Content "C:\Repo\SQL-Cluster-Sentry\inventory.txt"
$InventoryReport = @()
foreach ($Server in $ServerList) {
try {
# Run the "Truth Serum" SQL
$Topology = Invoke-Sqlcmd -ServerInstance $Server -InputFile "C:\Repo\SQL-Cluster-Sentry\Get-SqlTopology.sql" -ErrorAction Stop
$Object = [PSCustomObject]@{
ServerName = $Server
TrueIdentity = $Topology.ArchitectureType
CurrentRole = $Topology.Role
Partner = $Topology.FailoverPartner
}
$InventoryReport += $Object
Write-Host " [DETECTED] $Server is actually a $($Topology.ArchitectureType)" -ForegroundColor Green
}
catch {
Write-Warning "Could not contact $Server. It might be a passive FCI node or offline."
}
}
# Output the TRUTH, not what SSMS thinks
$InventoryReport | Format-Table -AutoSize