Skip to content

Fix #2678: Suppress Get-CimInstance access denied error#2695

Merged
nohwnd merged 2 commits into
pester:mainfrom
nohwnd:fix-2678-ciminstance
Jun 11, 2026
Merged

Fix #2678: Suppress Get-CimInstance access denied error#2695
nohwnd merged 2 commits into
pester:mainfrom
nohwnd:fix-2678-ciminstance

Conversation

@nohwnd

@nohwnd nohwnd commented Apr 3, 2026

Copy link
Copy Markdown
Member

Fix #2678

Added -ErrorAction Ignore to Get-CimInstance and Get-WmiObject calls in Get-RunTimeEnvironment with null fallback when not running as Administrator.

Copilot-generated fix.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

@nohwnd

nohwnd commented Apr 3, 2026

Copy link
Copy Markdown
Member Author

tests

Copilot-generated fix.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nohwnd nohwnd force-pushed the fix-2678-ciminstance branch from f34f9c8 to 5d6abc8 Compare April 3, 2026 10:18
@nohwnd

nohwnd commented Apr 3, 2026

Copy link
Copy Markdown
Member Author

🤖 Tests added in latest push — verifies Get-RunTimeEnvironment returns expected keys without throwing.

The previous tests were sanity smoke tests that passed even on the buggy
code (they only verified the function returned the expected hashtable
shape). Add a Windows-only test that stubs SafeCommands[Get-CimInstance]
to return $null (simulating access denied with -ErrorAction Ignore) and
asserts the Unknown / 0.0.0.0 fallback is applied.
@nohwnd nohwnd marked this pull request as ready for review June 11, 2026 15:43
@nohwnd nohwnd merged commit 9537037 into pester:main Jun 11, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get-CimInstance (non failing) error when running Pester not as Administrator

1 participant