· Uwe Janke
Commands / Get-sqmProviderInventory

Get-sqmProviderInventory

Inventory sqmSQLTool v1.9.226+ · Get Read-only
Collects everything a new hosting provider needs for sizing and feasibility in one read-only scan per server: operating system, hardware, volumes and disks, services, SQL Server configuration, a short load sample, databases with files and growth, backup history, Agent jobs, linked servers, AlwaysOn and clustering, and the security part (logins, database users, roles, permissions). The result is one self-contained HTML file per server. It holds the data and a viewer that needs no PowerShell, no Excel and no internet connection: open it in any browser.

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

ParameterTypeRequiredDefaultNotes
-SqlInstancestring[]Optionalall running instances on this computerA 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.
-SqlCredentialPSCredentialOptionalWindows authenticationSQL login if Windows authentication is not possible.
-OutputPathstringOptional<OutputPath config>\ProviderInventoryDirectory for the HTML file.
-ApplicationstringOptional, Application(s) of this server, separated by |. Can also be set later in the viewer; the viewer value wins.
-ParentGroupstringOptional, Parent group of this server. Same rule as -Application.
-IncludeAgentJobsswitchSwitch$falseAlso collect Agent job details (name, owner, schedule, last run, external references). Without it only the job count is collected.
-SkipSecurityswitchSwitch$falseDo not collect logins, database users, roles and permissions.
-SkipPerDatabaseswitchSwitch$falseDo 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.
-SampleSecondsintOptional10Length of the load sample (batch requests/s, transactions/s). 0 = no sample.
-BackupHistoryDaysintOptional30Window for backup duration and size statistics.
-QueryTimeoutSecondsintOptional120Timeout per SQL query.
-SaveJsonswitchSwitch$falseAlso write the raw scan as a .json file next to the HTML file.
-NoOpenswitchSwitch$falseDo not open the HTML file after the scan.
-AllReplicasboolOptional$trueAlwaysOn 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

START Host data via CIM/WMI (partner nodes remote) OS, CPU, RAM, volumes, disks, network, services, power plan Resolve instances host name: all running instances via CIM; HOST\INST or host,port: as given Per instance: one read-only pass configuration, load sample, databases, files, backups, jobs, linked servers AlwaysOn and cluster, logins and server permissions, local AG role per database AG database in SECONDARY role? YES Mark as secondary not opened, not an error NO Per database used space, tables, users, roles, permissions, cross-database references Any error in host or instances? YES No HTML, no JSON warnings + one error HtmlFile = $null NO Write one HTML file: data + viewer ProviderInventory_<COMPUTER>_<timestamp>.html, with -SaveJson also the raw .json opened unless -NoOpen; AlwaysOn: same steps for every partner node (-AllReplicas) END

Return value

One summary object per scanned node: this computer plus, with -AllReplicas, each AlwaysOn partner node.

PropertyMeaning
ComputerNameThe scanned computer (for a partner node its own name).
InstancesNumber of scanned instances.
DatabaseCountDatabases on the reachable instances (including tempdb and secondary databases).
ErrorCountNumber of errors. Greater than 0 means no file was written.
DurationSecScan duration in seconds.
HtmlFilePath of the HTML file, $null on error.
JsonFilePath 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