Commands / Get-sqmServerSetting
Get-sqmServerSetting
Configuration sqmSQLTool v1.8.2+ · Utility
Reads instance properties from a SQL Server instance. Retrieve a single property by name or use -All to return all properties at once.

Supported properties include: BackupDirectory, DefaultFile, DefaultLog, MasterDBPath, ErrorLogPath, ComputerName, InstanceName, Edition, VersionString, ProductLevel, ProductUpdateLevel, HostPlatform, IsClustered, IsHadrEnabled.

Parameters

ParameterTypeRequiredDefaultNotes
-SqlInstancestringOptional$env:COMPUTERNAMETarget SQL Server instance.
-SqlCredentialPSCredentialOptionalCredentials for the connection.
-NamestringOptionalSingle property name (ValidateSet). Returns scalar value.
-AllswitchOptional$falseReturn all properties as [PSCustomObject[]] (Name, Value, Type).
-DefaultValuestringOptionalFallback value if property doesn't exist (ignored with -All).
-EnableExceptionswitchOptional$falseRe-throw exceptions instead of Write-Error.

Execution Flow

START dbatools available? NO throw: dbatools not found YES Connect-DbaInstance Retrieve server SMO object -All set? YES Get all properties PSObject.Properties NO Return [PSCustomObject[]] or scalar value -All: (Name, Value, Type) array | -Name: property value DONE

Examples

Read a single property (BackupDirectory)
$backupPath = Get-sqmServerSetting -Name "BackupDirectory"
List all instance properties
Get-sqmServerSetting -All
Get all properties from remote instance with credentials
$cred = Get-Credential
Get-sqmServerSetting -SqlInstance "SQL01" -SqlCredential $cred -All