Thor Logo dbatools

Get-DbaCmConnection

View Source
Friedrich Weinmann (@FredWeinmann)
Windows, Linux, macOS

Synopsis

Retrieves cached Windows Management and CIM connections used by dbatools commands

Description

Shows which remote computer connections are currently cached by dbatools for Windows Management and CIM operations. This helps you understand what authentication contexts are active and troubleshoot connection issues when running dbatools commands against remote SQL Server instances. Cached connections are automatically created when you run dbatools commands that need to access Windows services, registry, or file system on remote servers.

Syntax

Get-DbaCmConnection
    [[-ComputerName] <String[]>]
    [[-UserName] <String>]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Get-DbaCmConnection

List all cached connections.

Example: 2
PS C:\> Get-DbaCmConnection sql2014

List the cached connection - if any - to the server sql2014.

Example: 3
PS C:\> Get-DbaCmConnection -UserName "*charles*"

List all cached connection that use a username containing “charles” as default or override credentials.

Optional Parameters

-ComputerName

Filters cached connections by computer name or server name. Supports wildcards for pattern matching.
Use this to check connections to specific SQL Server hosts or to search for connections matching a pattern like “sqlprod”.

PropertyValue
AliasFilter
RequiredFalse
Pipelinetrue (ByValue)
Default Value*
-UserName

Filters cached connections by the username in the stored credentials. Supports wildcards for pattern matching.
Use this to find connections using specific service accounts or domain credentials. Will not match connections using integrated Windows authentication.

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

Dataplat.Dbatools.Connection.ManagementConnection

Returns one ManagementConnection object per cached connection matching the filter criteria. Each object represents a cached remote computer management connection that dbatools uses for Windows Management and CIM operations.

Default display properties (displayed in table format):

  • ComputerName: The name of the remote computer that this connection is cached for
  • Available: Whether any connection protocol (CIM, WMI, or PowerShell Remoting) is available to this computer
  • User: The username being used for this connection (either from stored credentials or the current Windows user)
  • OverrideExplicitCredential: Boolean indicating if this connection ignores explicitly provided credentials and uses cached ones instead
  • DisabledConnectionTypes: Which connection protocols are disabled for this computer (CimRM, CimDCOM, Wmi, PowerShellRemoting, or combinations)

Additional properties available on the object (use Select-Object * to view all):

  • Credentials: The stored PSCredential object used for this connection (if any). Contains UserName property.
  • UseWindowsCredentials: Boolean indicating if Windows authentication should be used
  • DisableBadCredentialCache: Boolean indicating if failed credentials are not cached for this computer
  • DisableCimPersistence: Boolean indicating if CIM sessions are not reused for this computer
  • DisableCredentialAutoRegister: Boolean indicating if successful credentials are not automatically cached
  • WindowsCredentialsAreBad: Boolean indicating if Windows authentication has been marked as non-functional
  • CimRM: Connection test result for CIM over WinRM protocol (Success or Error)
  • CimDCOM: Connection test result for CIM over DCOM protocol (Success or Error)
  • Wmi: Connection test result for WMI protocol (Success or Error)
  • PowerShellRemoting: Connection test result for PowerShell Remoting protocol (Success or Error)
  • CimWinRMOptions: Advanced WinRM session options configured for this connection
  • CimDCOMOptions: Advanced DCOM session options configured for this connection