salt.modules.win_dsc_resource#
Module for invoking individual PowerShell DSC Resources directly using
Invoke-DscResource.
This module allows Salt to apply, test, and retrieve the state of any installed PowerShell DSC resource without compiling a MOF file or involving the Local Configuration Manager (LCM).
Use the psget module to install DSC resource modules from the PowerShell
Gallery before using them here.
New in version 3008.1.
- depends:
pythonnet
PowerShell 5.0
- salt.modules.win_dsc_resource.get(name, module_name, properties)#
Return the current state of a DSC resource by calling
Invoke-DscResource -Method Get.- Parameters:
name (str) -- The name of the DSC resource to query. For example,
WindowsFeatureorFile. Required.module_name (str) -- The name of the PowerShell module that contains the resource. For built-in resources use
PSDesiredStateConfiguration. Required.properties (dict) -- A dictionary of resource properties sufficient to identify the resource instance. The required keys vary by resource. Required.
- Returns:
A dictionary of the resource's current property values as reported by the DSC resource's
Getmethod.- Return type:
- Raises:
CommandExecutionError -- If the PowerShell call fails.
SaltInvocationError -- If required arguments are missing or invalid.
CLI Example:
salt '*' dsc_resource.get File PSDesiredStateConfiguration \ properties="{'DestinationPath': 'C:\\Temp\\test.txt', 'Ensure': 'Present'}"
salt '*' dsc_resource.get WindowsFeature PSDesiredStateConfiguration \ properties="{'Name': 'Web-Server', 'Ensure': 'Present'}"
New in version 3008.1.
- salt.modules.win_dsc_resource.set_(name, module_name, properties)#
Apply a DSC resource to the desired state by calling
Invoke-DscResource -Method Set.- Parameters:
- Returns:
Trueif the resource was applied successfully.- Return type:
- Raises:
CommandExecutionError -- If the resource failed to apply.
SaltInvocationError -- If required arguments are missing or invalid.
CLI Example:
salt '*' dsc_resource.set File PSDesiredStateConfiguration \ properties="{'DestinationPath': 'C:\\Temp\\test.txt', 'Ensure': 'Present', 'Contents': 'hello'}"
salt '*' dsc_resource.set WindowsFeature PSDesiredStateConfiguration \ properties="{'Name': 'Web-Server', 'Ensure': 'Present'}"
New in version 3008.1.
- salt.modules.win_dsc_resource.test(name, module_name, properties)#
Test whether a DSC resource is in the desired state by calling
Invoke-DscResource -Method Test.- Parameters:
- Returns:
Trueif the resource is already in the desired state,Falseif changes are needed.- Return type:
- Raises:
CommandExecutionError -- If the PowerShell call fails.
SaltInvocationError -- If required arguments are missing or invalid.
CLI Example:
salt '*' dsc_resource.test File PSDesiredStateConfiguration \ properties="{'DestinationPath': 'C:\\Temp\\test.txt', 'Ensure': 'Present'}"
salt '*' dsc_resource.test WindowsFeature PSDesiredStateConfiguration \ properties="{'Name': 'Web-Server', 'Ensure': 'Present'}"
New in version 3008.1.