Thor Logo dbatools

Get-DbaFeature

View Source
Chrissy LeMaire (@cl), netnerds.net
Windows, Linux, macOS

Synopsis

Discovers installed SQL Server features and components across multiple servers

Description

Executes SQL Server’s built-in feature discovery report to inventory all installed SQL Server components, editions, and instances across one or more servers. This function automates the manual process of running setup.exe /Action=RunDiscovery and parsing the resulting XML report, making it perfect for compliance auditing, license tracking, and environment documentation.

The function returns structured data showing exactly what SQL Server features are installed, which instances they belong to, their versions, editions, and configuration status. This is essential for DBAs who need to understand their SQL Server landscape without manually checking each server or running discovery reports individually.

Inspired by Dave Mason’s (@BeginTry) post at
https://itsalljustelectrons.blogspot.be/2018/04/SQL-Server-Discovery-Report.html

Assumptions:

  1. The sub-folder “Microsoft SQL Server” exists in [System.Environment]::GetFolderPath(“ProgramFiles”),
    even if SQL was installed to a non-default path. This has been
    verified on SQL 2008R2 and SQL 2012. Further verification may be needed.
  2. The discovery report displays installed components for the version of SQL
    Server associated with setup.exe, along with installed components of all
    lesser versions of SQL Server that are installed.

Syntax

Get-DbaFeature
    [[-ComputerName] <DbaInstanceParameter[]>]
    [[-Credential] <PSCredential>]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Get-DbaFeature -ComputerName sql2017, sql2016, sql2005

Gets all SQL Server features for all instances on sql2017, sql2016 and sql2005.

Example: 2
PS C:\> Get-DbaFeature -Verbose

Gets all SQL Server features for all instances on localhost. Outputs to screen if no instances are found.

Example: 3
PS C:\> Get-DbaFeature -ComputerName sql2017 -Credential ad\sqldba

Gets all SQL Server features for all instances on sql2017 using the ad\sqladmin credential (which has access to the Windows Server).

Optional Parameters

-ComputerName

Specifies the Windows computer names where you want to discover SQL Server features and components. Accepts multiple computers for bulk discovery operations.
Use this when you need to inventory SQL Server installations across your environment for compliance auditing or license tracking.
Requires PowerShell remoting to be enabled on remote computers. Note that this targets the Windows host, not SQL instance names.

PropertyValue
Alias
RequiredFalse
Pipelinetrue (ByValue)
Default Value$env:COMPUTERNAME
-Credential

Allows you to login to servers using alternative credentials. To use:
$cred = Get-Credential, then pass $cred object to the -Credential parameter.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with “sea of red” exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this “nice by default” feature off and enables you to catch exceptions with your own try/catch.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse

Outputs

PSCustomObject

Returns one object per SQL Server feature component discovered. Multiple objects are returned when multiple SQL Server versions or instances with different installed features are found on the target server(s).

Properties:

  • ComputerName: The name of the Windows server where SQL Server is installed
  • Product: The SQL Server product name (e.g., “SQL Server 2019 Enterprise Edition”)
  • Instance: The SQL Server instance name, or “MSSQLSERVER” for the default instance
  • InstanceID: The SQL Server instance ID identifier from the registry
  • Feature: The specific SQL Server component that is installed (e.g., Database Engine, Analysis Services, Reporting Services, Integration Services, Replication, Full-Text Search)
  • Language: The language/locale of the SQL Server installation (e.g., “English”)
  • Edition: The SQL Server edition (Enterprise, Standard, Express, Developer, Evaluation, Web)
  • Version: The version number of SQL Server in format (e.g., “15.0.2000.5”)
  • Clustered: Boolean indicating if this SQL Server instance is part of a failover cluster (True/False)
  • Configured: Boolean indicating if the SQL Server component is fully configured and operational (True/False) Each row represents one installed feature. A single SQL Server instance with multiple installed features will generate multiple objects.