Update-ServiceStatus - Fix WinRM error on machines without WinRM configured#10274
Draft
andreasjordan wants to merge 3 commits intodevelopmentfrom
Draft
Update-ServiceStatus - Fix WinRM error on machines without WinRM configured#10274andreasjordan wants to merge 3 commits intodevelopmentfrom
andreasjordan wants to merge 3 commits intodevelopmentfrom
Conversation
…ace boundaries When CIM instances are passed across runspace boundaries (via Invoke-Parallel), they become deserialized and lose their CIM session context. Subsequent calls to Invoke-CimMethod and Get-CimInstance then attempt to create a new connection using WinRM by default, which fails on machines where WinRM is not configured. The fix creates a DCOM-based CIM session inside the runspace scriptblock, avoiding the WinRM dependency. The session is used to obtain fresh CIM instances before invoking service control methods, and for polling service state during restart. Falls back to WinRM if DCOM is unavailable. Fixes #9782 (do *Service*) Co-authored-by: Andreas Jordan <andreasjordan@users.noreply.github.com>
Collaborator
Author
|
This needs more testing in my lab before merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9782
Problem
When CIM instances are passed across runspace boundaries (via Invoke-Parallel), they become deserialized and lose their CIM session context. Subsequent calls to
Invoke-CimMethodandGet-CimInstancethen attempt to create a new connection using WinRM by default, which fails on machines where WinRM is not configured (e.g. fresh Azure VMs, machines before runningwinrm quickconfig).This affected
Enable-DbaAgHadr,Set-DbaNetworkConfiguration -RestartService, and any other command that callsRestart-DbaService/Stop-DbaService.Fix
Modified
$svcControlBlockinUpdate-ServiceStatus.ps1to create a DCOM-based CIM session inside the runspace, which does not require WinRM. The session is used to get fresh CIM instances before invoking service control methods and for polling service state. Falls back to WinRM if DCOM is unavailable.Generated with Claude Code