Skip to content

Commit 672bbe8

Browse files
Get-DbaCmObject - Apply CimOperationTimeout config to all CIM connections
Ensures CimWinRMOptions and CimDCOMOptions are initialized with the ComputerManagement.CimOperationTimeout config value (default: 60s) whenever Get-DbaCmObject retrieves a connection, not only when New-DbaCmConnection or Set-DbaCmConnection are explicitly called. This prevents indefinite hangs when querying servers with hung or corrupted WMI. Fixes #6498 Co-authored-by: Andreas Jordan <andreasjordan@users.noreply.github.com>
1 parent 63c906f commit 672bbe8

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

public/Get-DbaCmObject.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,14 @@ function Get-DbaCmObject {
255255

256256
$connection = $connectionObject.Connection
257257

258+
# Ensure CIM session options are initialized with the configured operation timeout
259+
if ($null -eq $connection.CimWinRMOptions) {
260+
$connection.CimWinRMOptions = New-DbaCimSessionOptionWithTimeout -Protocol Default
261+
}
262+
if ($null -eq $connection.CimDCOMOptions) {
263+
$connection.CimDCOMOptions = New-DbaCimSessionOptionWithTimeout -Protocol Dcom
264+
}
265+
258266
# Ensure using the right credentials
259267
try { $cred = $connection.GetCredential($Credential) }
260268
catch {

0 commit comments

Comments
 (0)