Add context() function and refactor osinfo#1103
Merged
SteveL-MSFT merged 7 commits intoPowerShell:mainfrom Sep 15, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new context() function that provides both OS information and security context for conditional execution. It also refactors the osinfo module by extracting shared functionality into a library.
- Creates a new
context()function returning OS info and security context in a single object - Refactors osinfo to use a shared library (
osinfo_lib) for code reuse - Updates OSInfo to version 1.0.0 with breaking changes to the bitness field format
Reviewed Changes
Copilot reviewed 9 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| osinfo/src/main.rs | Refactored to use the new osinfo_lib library instead of local config module |
| osinfo/Cargo.toml | Updated version to 1.0.0 and replaced direct dependencies with osinfo_lib |
| lib/osinfo_lib/src/lib.rs | New library with refactored OsInfo struct, removing $id field and changing bitness to Option |
| lib/osinfo_lib/cargo.toml | New cargo configuration for the osinfo library |
| dsc_lib/src/functions/mod.rs | Added the new context function to the function dispatcher |
| dsc_lib/src/functions/context.rs | New context function implementation |
| dsc_lib/Cargo.toml | Added osinfo_lib dependency |
| dsc/tests/dsc_functions.tests.ps1 | Added test coverage for the new context function |
| build.ps1 | Updated build script to include the new osinfo_lib |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
tgauth
approved these changes
Sep 15, 2025
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.
PR Summary
Add a new
context()function that returns an object that contains both os info and security context. This can be used forcondition:execution.This involved refactoring
osinfowhere the main part is now a lib used by the function and theOSInforesource. UpdatedOSinforesource to version 1.0.0 as there's now a breaking change. Bitness is no longer a string, but instead is a number or not returned if it cannot be determined.PR Context
Fix #1012