-
Notifications
You must be signed in to change notification settings - Fork 48
Add Bicep example #806
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
base: main
Are you sure you want to change the base?
Add Bicep example #806
Changes from 12 commits
40f663c
159fe7c
d6f044a
97cfa4b
cd96c7c
07b332f
b50b617
2618791
798a77f
4f7b56d
3fc3ddc
02be5f1
6e11216
b77b2fd
d2c9cd3
20af2f0
63ae084
210684b
3dd00e4
79a8a9f
bf0ed8f
72a0468
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// This example demonstrates how to create a file using the Windows PowerShell DSC extension. | ||
// The file is created in the C:\DSC directory on the target machine. | ||
// You should at least have the Bicep CLI v0.34.34 installed to run this example with experimental feature desiredStateConfiguration turned on. | ||
// To run the second resource, you can add the --parameters '{"parameters":{"restartService":true}}' flag to the command line. | ||
|
||
targetScope = 'desiredStateConfiguration' | ||
|
||
@description('Set to true to ensure the service is running after the file creation.') | ||
param restartService bool = false | ||
|
||
resource powerShellAdapter 'Microsoft.Windows/WindowsPowerShell@2025-01-07' = { | ||
name: 'Use Bicep to create file' | ||
properties: { | ||
resources: [ | ||
{ | ||
name: 'File' | ||
type: 'PSDesiredStateConfiguration/File' | ||
properties: { | ||
Ensure: 'Present' | ||
Type: 'File' | ||
DestinationPath: 'C:\\DSC\\config.txt' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of hardcoding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only if that was possible. I have created an issue on Bicep repository. Do you mind pulling in the example for now? |
||
Contents: 'This file was created using Bicep extension from DSC.' | ||
} | ||
} | ||
] | ||
} | ||
} | ||
|
||
// Optionally ensure the service is running after the file creation | ||
resource ensureServiceRunning 'PSDesiredStateConfiguration/Service@2025-01-07' = if (restartService) { | ||
name: 'Ensure DSC service is running' | ||
properties: { | ||
Name: 'Spooler' | ||
StartupType: 'Automatic' | ||
State: 'Running' | ||
} | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.