Get-sqmProviderInventory
Inventory
sqmSQLTool v1.9.226+ · Get
Read-only
The viewer. Drop the HTML files of other servers onto it to merge them, assign application and parent group per server, switch the security data on or off, anonymize server names, and export the provider view as CSV, Excel (.xlsx) or as a reduced HTML file without security data. A second scan for the security part is never needed. The viewer's tab names are German (for example
Datenbanken, HA-DR, Pruefbericht).
Read-only. Only metadata views and DMVs are read, no user table is scanned. Job step commands are not stored because they may contain secrets; only the external references found in them (UNC paths, linked servers, OPENQUERY) are kept. Host data comes from the local CIM/WMI classes, so run the function on the server itself and as local administrator.
Only complete inventories (v1.9.240+). If anything cannot be read (a section, an unreachable instance, no instance found), no HTML file and no JSON file are written. Every error is shown as a warning, followed by one non-terminating error, and the returned object has
HtmlFile = $null. Fix the cause and scan again. Without local administrator rights parts of the OS data (for example the power plan) fail, so the scan then produces no file.
AlwaysOn secondary nodes (v1.9.241+). On a secondary replica the availability group databases are not opened. They are listed with their AG name and the role
SECONDARY, are marked in the viewer (AG-Rolle, Sekundaer-DB: "ja (nicht gescannt)") and do not count as errors, so the secondary node still gets its HTML file. File sizes, state, recovery model and backup history are still included; used space, tables and security data of those databases come from the primary's scan.
All AlwaysOn nodes in one run (v1.9.242+). With
-AllReplicas (default $true) the hosts of all partner replicas of every availability group found are scanned in the same run, each with its own HTML file. Host data of a partner node is read remotely via CIM (WSMan, fallback DCOM), so the account needs local administrator rights and WinRM or DCOM access there. All running instances of the partner host are scanned. A partner node with an error gets no file; the other nodes are not affected. Without AlwaysOn the parameter has no effect.
Handle with care: the HTML file written by the function contains the security data (login names, permissions). Do not hand it to third parties; give the provider the viewer's reduced export instead.
Parameters
| Parameter | Type | Required | Default | Notes |
|---|---|---|---|---|
| -SqlInstance | string[] | Optional | all running instances on this computer | A bare host name (SQL01) discovers all running SQL Server instances of that host via CIM (v1.9.237+). SQL01\INST1 or SQL01,1434 scans exactly that instance. If the host cannot be queried via CIM or has no SQL service (AG listener, FCI network name), the name is used as given. OS and hardware data always come from the computer running the function. |
| -SqlCredential | PSCredential | Optional | Windows authentication | SQL login if Windows authentication is not possible. |
| -OutputPath | string | Optional | <OutputPath config>\ProviderInventory | Directory for the HTML file. |
| -Application | string | Optional | , | Application(s) of this server, separated by |. Can also be set later in the viewer; the viewer value wins. |
| -ParentGroup | string | Optional | , | Parent group of this server. Same rule as -Application. |
| -IncludeAgentJobs | switch | Switch | $false | Also collect Agent job details (name, owner, schedule, last run, external references). Without it only the job count is collected. |
| -SkipSecurity | switch | Switch | $false | Do not collect logins, database users, roles and permissions. |
| -SkipPerDatabase | switch | Switch | $false | Do not switch into each database (no used space, no database users, no cross-database references). Only for instances with a very large number of databases. |
| -SampleSeconds | int | Optional | 10 | Length of the load sample (batch requests/s, transactions/s). 0 = no sample. |
| -BackupHistoryDays | int | Optional | 30 | Window for backup duration and size statistics. |
| -QueryTimeoutSeconds | int | Optional | 120 | Timeout per SQL query. |
| -SaveJson | switch | Switch | $false | Also write the raw scan as a .json file next to the HTML file. |
| -NoOpen | switch | Switch | $false | Do not open the HTML file after the scan. |
| -AllReplicas | bool | Optional | $true | AlwaysOn only: also scan the hosts of all partner replicas, one HTML file per node (v1.9.242+). -AllReplicas $false scans only this computer. |
Execution Flow
Return value
One summary object per scanned node: this computer plus, with -AllReplicas, each AlwaysOn partner node.
| Property | Meaning |
|---|---|
ComputerName | The scanned computer (for a partner node its own name). |
Instances | Number of scanned instances. |
DatabaseCount | Databases on the reachable instances (including tempdb and secondary databases). |
ErrorCount | Number of errors. Greater than 0 means no file was written. |
DurationSec | Scan duration in seconds. |
HtmlFile | Path of the HTML file, $null on error. |
JsonFile | Path of the JSON file with -SaveJson, otherwise or on error $null. |
Examples
Scan all instances of this server (run as local administrator)
Get-sqmProviderInventory -OutputPath D:\Inventory
Clustered instance with application, parent group and Agent job details
Get-sqmProviderInventory -SqlInstance SQLCL01 -Application "SAP|DWH" -ParentGroup "Finance" -IncludeAgentJobs -NoOpen
Use in a script: stop when the inventory is incomplete
$r = Get-sqmProviderInventory -OutputPath D:\Inventory -NoOpen -ErrorAction Stop $r.HtmlFile
On an AlwaysOn node: scan only this computer, not the partner replicas
Get-sqmProviderInventory -AllReplicas $false
Without the security part and with the raw data as JSON
Get-sqmProviderInventory -SkipSecurity -SaveJson -OutputPath D:\Inventory