Here is a basic PowerShell script to set desired state configuration (DSC) for a Windows feature or role on a server:
configuration ExampleDSC { node <NodeName> { WindowsFeature <FeatureName> { Name = "<FeatureDisplayName>" Ensure = "Present" } } } # Compile the configuration into a MOF file ExampleDSC -OutputPath .\ExampleDSC # Apply the configuration to the node Start-DscConfiguration -Path .\ExampleDSC -Wait -Verbose
Replace <NodeName> with the name of the server you want to configure, and <FeatureName> and <FeatureDisplayName> with the name of the Windows feature or role you want to manage. The Ensure parameter can be set to either "Present" to ensure that the feature is installed, or "Absent" to ensure that it is not installed.
No comments:
Post a Comment