-
Notifications
You must be signed in to change notification settings - Fork 59
docs: Add reference documentation for Microsoft.Adapter/PowerShell and Microsoft.Adapter/WindowsPowerShell
#1444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Gijsreyn
wants to merge
2
commits into
PowerShell:main
Choose a base branch
from
Gijsreyn:update-adapter-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+822
−641
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
This file was deleted.
Oops, something went wrong.
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
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
89 changes: 89 additions & 0 deletions
89
...eference/resources/Microsoft/adapter/powershell/examples/configure-a-machine.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| --- | ||
| description: > | ||
| Example showing how to configure a machine using multiple class-based PowerShell DSC resources | ||
| with the Microsoft.Adapter/PowerShell adapter in a DSC configuration document. | ||
|
|
||
| ms.date: 03/23/2026 | ||
| ms.topic: reference | ||
| title: Configure a machine with the PowerShell adapter | ||
| --- | ||
|
|
||
| This example shows how to use the `Microsoft.Adapter/PowerShell` adapter to configure a machine | ||
| using multiple class-based PowerShell DSC resources in a single configuration document. These | ||
| examples use the `Microsoft.WinGet.DSC/WinGetPackage` resource from the **Microsoft.WinGet.DSC** | ||
| module to ensure several packages are installed. | ||
|
|
||
| > [!NOTE] | ||
| > Run this example with `dsc.exe` version 3.2.0 or later and the **Microsoft.WinGet.DSC** | ||
| > PowerShell module installed. Install the module with: | ||
| > `Install-PSResource Microsoft.WinGet.DSC` | ||
|
|
||
| ## Configuration document | ||
|
|
||
| The following configuration document defines multiple `Microsoft.WinGet.DSC/WinGetPackage` | ||
| instances. Each instance sets `directives.requireAdapter` to `Microsoft.Adapter/PowerShell`. | ||
|
|
||
| Save the following YAML as `dev-tools.dsc.yaml`: | ||
|
|
||
| ```yaml | ||
| $schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
| parameters: | ||
| ensureTools: | ||
| type: string | ||
| defaultValue: Present | ||
| allowedValues: | ||
| - Present | ||
| - Absent | ||
| resources: | ||
| - name: PowerShell 7 | ||
| type: Microsoft.WinGet.DSC/WinGetPackage | ||
| directives: | ||
| requireAdapter: Microsoft.Adapter/PowerShell | ||
| properties: | ||
| Id: Microsoft.PowerShell | ||
| Ensure: "[parameters('ensureTools')]" | ||
| - name: Windows Terminal | ||
| type: Microsoft.WinGet.DSC/WinGetPackage | ||
| directives: | ||
| requireAdapter: Microsoft.Adapter/PowerShell | ||
| properties: | ||
| Id: Microsoft.WindowsTerminal | ||
| Ensure: "[parameters('ensureTools')]" | ||
| - name: Visual Studio Code | ||
| type: Microsoft.WinGet.DSC/WinGetPackage | ||
| directives: | ||
| requireAdapter: Microsoft.Adapter/PowerShell | ||
| properties: | ||
| Id: Microsoft.VisualStudioCode | ||
| Ensure: "[parameters('ensureTools')]" | ||
| ``` | ||
|
|
||
| ## Test the configuration | ||
|
|
||
| Run the configuration test to check whether the packages are installed: | ||
|
|
||
| ```powershell | ||
| dsc config test --file dev-tools.dsc.yaml | ||
| ``` | ||
|
|
||
| DSC reports the results for each instance, showing which packages need to be installed. | ||
|
|
||
| ## Apply the configuration | ||
|
|
||
| Run the configuration set to install any packages that aren't already present: | ||
|
|
||
| ```powershell | ||
| dsc config set --file dev-tools.dsc.yaml | ||
| ``` | ||
|
|
||
| ## Remove the packages | ||
|
|
||
| To uninstall the packages, override the `ensureTools` parameter when applying the configuration: | ||
|
|
||
| ```powershell | ||
| dsc config set --file dev-tools.dsc.yaml --parameters '{"ensureTools": "Absent"}' | ||
| ``` | ||
|
|
||
| <!-- Link references --> | ||
| [01]: ../../../../../../cli/config/test.md | ||
| [02]: ../../../../../../cli/config/set.md |
117 changes: 117 additions & 0 deletions
117
.../reference/resources/Microsoft/adapter/powershell/examples/invoke-a-resource.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| --- | ||
| description: > | ||
| Example showing how to invoke a class-based PowerShell DSC resource using | ||
| Microsoft.Adapter/PowerShell in a DSC configuration document. | ||
| ms.date: 03/23/2026 | ||
| ms.topic: reference | ||
| title: Invoke a resource with the PowerShell adapter | ||
| --- | ||
|
|
||
| This example shows how to use the `Microsoft.Adapter/PowerShell` adapter to invoke a class-based | ||
| PowerShell DSC resource. These examples use the `Microsoft.WinGet.DSC/WinGetPackage` resource from | ||
| the **Microsoft.WinGet.DSC** module to check whether Windows Terminal is installed. | ||
|
|
||
| > [!NOTE] | ||
| > Run this example with `dsc.exe` version 3.2.0 or later and the **Microsoft.WinGet.DSC** | ||
| > PowerShell module installed. Install the module with: | ||
| > `Install-PSResource Microsoft.WinGet.DSC` | ||
|
|
||
| ## Test whether a WinGet package is installed | ||
|
|
||
| The following configuration document defines a single `Microsoft.WinGet.DSC/WinGetPackage` | ||
| instance that uses `directives.requireAdapter` to route the resource through the | ||
| `Microsoft.Adapter/PowerShell` adapter. | ||
|
|
||
| Save the following YAML as `winget-test.dsc.yaml`: | ||
|
|
||
| ```yaml | ||
| $schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
| resources: | ||
| - name: Windows Terminal | ||
| type: Microsoft.WinGet.DSC/WinGetPackage | ||
| directives: | ||
| requireAdapter: Microsoft.Adapter/PowerShell | ||
| properties: | ||
| Id: Microsoft.WindowsTerminal | ||
| Ensure: Present | ||
| ``` | ||
|
|
||
| Run the configuration test operation to check whether Windows Terminal is installed: | ||
|
|
||
| ```powershell | ||
| dsc config test --file winget-test.dsc.yaml | ||
| ``` | ||
|
|
||
| When the package isn't installed, DSC returns the following result: | ||
|
|
||
| ```yaml | ||
| metadata: | ||
| Microsoft.DSC: | ||
| version: 3.2.0 | ||
| operation: test | ||
| executionType: actual | ||
| startDatetime: '2026-03-23T00:00:00.000000000+00:00' | ||
| endDatetime: '2026-03-23T00:00:01.000000000+00:00' | ||
| duration: PT1S | ||
| securityContext: restricted | ||
| results: | ||
| - metadata: | ||
| Microsoft.DSC: | ||
| duration: PT0.5S | ||
| name: Windows Terminal | ||
| type: Microsoft.WinGet.DSC/WinGetPackage | ||
| result: | ||
| desiredState: | ||
| Id: Microsoft.WindowsTerminal | ||
| Ensure: Present | ||
| actualState: | ||
| Id: Microsoft.WindowsTerminal | ||
| Ensure: Absent | ||
| inDesiredState: false | ||
| differingProperties: | ||
| - Ensure | ||
| messages: [] | ||
| hadErrors: false | ||
| ``` | ||
|
|
||
| The `inDesiredState` field is `false` and `differingProperties` shows that `Ensure` differs between | ||
| the desired state and the actual state. | ||
|
|
||
| ## Install a WinGet package | ||
|
|
||
| Use the `dsc config set` command to configure the system to the desired state: | ||
|
|
||
| ```powershell | ||
| dsc config set --file winget-test.dsc.yaml | ||
| ``` | ||
|
|
||
| When the resource installs the package, DSC returns the following result: | ||
|
|
||
| ```yaml | ||
| metadata: | ||
| Microsoft.DSC: | ||
| version: 3.2.0 | ||
| operation: set | ||
| executionType: actual | ||
| startDatetime: '2026-03-23T00:00:00.000000000+00:00' | ||
| endDatetime: '2026-03-23T00:00:05.000000000+00:00' | ||
| duration: PT5S | ||
| securityContext: restricted | ||
| results: | ||
| - metadata: | ||
| Microsoft.DSC: | ||
| duration: PT4S | ||
| name: Windows Terminal | ||
| type: Microsoft.WinGet.DSC/WinGetPackage | ||
| result: | ||
| beforeState: | ||
| Id: Microsoft.WindowsTerminal | ||
| Ensure: Absent | ||
| afterState: | ||
| Id: Microsoft.WindowsTerminal | ||
| Ensure: Present | ||
| changedProperties: | ||
| - Ensure | ||
| messages: [] | ||
| hadErrors: false | ||
| ``` |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR description says
docs/get-started/index.mdwas updated, but in this PR it appears to be removed entirely. If the deletion is intentional, the PR description should be updated; otherwise, the file likely needs to be restored/updated instead of deleted.