DSC
DSC copied to clipboard
Copy loop iteration
Summary of the new feature / enhancement
As a user, I would expect you to be able to use the copy
operation with a counter in the resource configuration document. This allows me to either drive resource configurations through the --parameters-file
parameter or --path
when doing an operation.
What I would expect is the following:
# test.parameters.yaml
parameters:
applications:
- name: PowerShell
id: 'Microsoft.PowerShell.Preview'
# test.config.yaml
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
parameters:
applications:
type: object
resources:
- name: Use class PowerShell resources
type: Microsoft.DSC/PowerShell
properties:
copy:
resources:
- name: PowerShell 7 Preview
type: Microsoft.WinGet.DSC/WinGetPackage
properties:
Id: "[parameters('applications.name').id]"
Ensure: "Absent"
Other scenarios I'm thinking of, are the famously known DTAP street with configuration for Computer Management.
Imagine you want to add users/groups to the relevant groups like Adminstrator, or Remote Desktop Users. Organizations can follow naming conventions as `<groupname.<environmentName>.<regionName>', helping drive configurations from parameter files.
You will in turn get something like:
# dev.group.parameters.yaml
parameters:
groups:
- name: Admin Group
groupName: 'Administrators'
members: ['testuser1', 'testuser2']
- name: 'Remote Users'
# truncated
# group.config.yaml
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
parameters:
groups:
type: object
resources:
- name: Use class PowerShell resources
type: Microsoft.DSC/PowerShell
properties:
copy:
resources:
- name: PowerShell 7 Preview
type: PSDscResources/GroupSet
properties:
GroupName "[parameters('name').groupName]"
Members "[parameters('name').members]"
Ensure: "Present"
It's a bit short, but if you want to expand on the idea, just give me a headsup.
You would then be able to call it with the command line as such:
dsc.exe config -f <environmentName>.groups.parameters.yaml set -p groups.config.yaml
Proposed technical implementation details (optional)
No response