Skip to content

Commit e04e10b

Browse files
committed
Add two examples
1 parent c4c8c5b commit e04e10b

File tree

3 files changed

+172
-5
lines changed

3 files changed

+172
-5
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
description: >
3+
Demonstrates how to install a package with the DSC.PackageManagement/Brew resource
4+
ms.date: 07/03/2025
5+
ms.topic: reference
6+
title: Install a package with Brew
7+
---
8+
9+
# Install a package with Brew
10+
11+
This example demonstrates how to use the `DSC.PackageManagement/Brew` resource to install a package
12+
on MacOS systems using Brew.
13+
14+
## Test if package is installed
15+
16+
The following snippet shows how you can use the resource with the [dsc resource test][00] command
17+
to check whether the `node` package exists.
18+
19+
```bash
20+
dsc resource test --resource DSC.PackageManagement/Brew --input '{"packageName":"node"}'
21+
```
22+
23+
When the package is not installed, DSC returns the following result.
24+
25+
```yaml
26+
desiredState:
27+
packageName: node
28+
actualState:
29+
_exist: false
30+
packageName: node
31+
version: ""
32+
inDesiredState: false
33+
differingProperties:
34+
- _exist
35+
```
36+
37+
## Ensure a package is installed
38+
39+
To ensure the system is in the desired state, use the [dsc resource set][01]
40+
command.
41+
42+
```bash
43+
dsc resource set --resource DSC.PackageManagement/Brew --input '{"packageName":"node"}'
44+
```
45+
46+
When the resource installs the package, DSC returns the following result:
47+
48+
```yaml
49+
beforeState:
50+
packageName: "node"
51+
version: ""
52+
_exist: false
53+
afterState:
54+
_exist: true
55+
packageName: node
56+
version: "24.3.0"
57+
changedProperties:
58+
- _exist
59+
- version
60+
```
61+
62+
> [!NOTE]
63+
> Note that the version can differ depending on your system's package repositories
64+
> and available package versions.
65+
66+
You can test the instance again to confirm that the package exists:
67+
68+
```bash
69+
dsc resource test --resource DSC.PackageManagement/Brew --input '{"packageName":"node"}'
70+
```
71+
72+
```yaml
73+
desiredState:
74+
packageName: node
75+
actualState:
76+
_exist: true
77+
packageName: node
78+
version: "24.3.0"
79+
inDesiredState: true
80+
differingProperties: []
81+
```
82+
83+
<!-- Link reference definitions -->
84+
[00]: ../../../../../cli/resource/test.md
85+
[01]: ../../../../../cli/resource/set.md
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
description: >
3+
Demonstrates how to remove a package with the DSC.PackageManagement/Brew resource
4+
ms.date: 07/03/2025
5+
ms.topic: reference
6+
title: Remove a package with Brew
7+
---
8+
9+
# Remove a package with Brew
10+
11+
This example demonstrates how to use the `DSC.PackageManagement/Brew` resource to remove a package
12+
on MacOS systems using Brew.
13+
14+
## Test if package is installed
15+
16+
The following snippet shows how you can use the resource with the [dsc resource test][00] command
17+
to check whether the `node` package doesn't exists.
18+
19+
```bash
20+
dsc resource test --resource DSC.PackageManagement/Brew --input '{"packageName":"node","_exist":false}'
21+
```
22+
23+
When the package is installed, DSC returns the following result.
24+
25+
```yaml
26+
desiredState:
27+
packageName: node
28+
_exist: false
29+
actualState:
30+
_exist: true
31+
packageName: node
32+
version: "24.3.0"
33+
inDesiredState: false
34+
differingProperties:
35+
- _exist
36+
```
37+
38+
## Ensure a package is removed
39+
40+
To ensure the system is in the desired state, use the [dsc resource set][01]
41+
command.
42+
43+
```bash
44+
dsc resource set --resource DSC.PackageManagement/Brew --input '{"packageName":"node","_exist":false}'
45+
```
46+
47+
When the resource removes the package, DSC returns the following result:
48+
49+
```yaml
50+
beforeState:
51+
packageName: "node"
52+
version: "24.3.0"
53+
_exist: true
54+
afterState:
55+
_exist: false
56+
packageName: node
57+
version: ""
58+
changedProperties:
59+
- _exist
60+
- version
61+
```
62+
63+
You can test the instance again to confirm that the package has been removed:
64+
65+
```bash
66+
dsc resource test --resource DSC.PackageManagement/Brew --input '{"packageName":"node","_exist":false}'
67+
```
68+
69+
```yaml
70+
desiredState:
71+
packageName: node
72+
_exist: false
73+
actualState:
74+
_exist: false
75+
packageName: node
76+
version: ""
77+
inDesiredState: true
78+
differingProperties: []
79+
```
80+
81+
<!-- Link reference definitions -->
82+
[00]: ../../../../../cli/resource/test.md
83+
[01]: ../../../../../cli/resource/set.md

docs/reference/resources/DSC/PackageManagement/Brew/index.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,13 @@ exit code, it also emits an error message with details about the invalid paramet
195195
## See also
196196

197197
- [DSC.PackageManagement/Apt resource][03]
198-
- [For more information about Homebrew][07]
198+
- [For more information about Homebrew][06]
199199

200200
<!-- Link definitions -->
201201
[00]: ../../../../../concepts/resources/capabilities.md
202202
[01]: ../../../../../concepts/resources/properties.md#required-resource-properties
203203
[02]: ../../../../../concepts/resources/properties.md#key-resource-properties
204204
[03]: ../APT/index.md
205-
[04]: ./examples/install-package-with-brew.md
206-
[05]: ./examples/install-specific-version.md
207-
[06]: ./examples/remove-package.md
208-
[07]: https://brew.sh/
205+
[04]: ./examples/install-a-package-with-brew.md
206+
[05]: ./examples/remove-a-package.md
207+
[06]: https://brew.sh/

0 commit comments

Comments
 (0)