Scripts provides a mechanism to run PowerShell script blocks on a target node.
Source |
|
DSC Resource |
|
Documentation |
Parameter | Attribute | DataType | Description | Allowed Values |
---|---|---|---|---|
hashtable[] |
The xScript DSC resource provides a mechanism to run PowerShell script blocks on a target node.. |
Parameter | Attribute | DataType | Description | Allowed Values |
---|---|---|---|---|
Name |
Key |
String |
Script Name |
|
Params |
Hashtable[] |
Optional script paramters as Key-Value hashtable You can access these parameters with the variable |
||
GetScript |
String |
A string that can be used to create a PowerShell script block that retrieves the current state of the resource. This script block runs when the Get-DscConfiguration cmdlet is called. This script block should return a hash table containing one key named Result with a string value. If the |
||
SetScript |
String |
A string that can be used to create a PowerShell script block that sets the resource to the desired state. This script block runs conditionally when the Start-DscConfiguration cmdlet is called. The TestScript script block will run first. If the TestScript block returns False, this script block will run. If the TestScript block returns True, this script block will not run. This script block should not return. If the |
||
TestScript |
Mandatory |
String |
A string that can be used to create a PowerShell script block that validates whether or not the resource is in the desired state.
This script block runs when the Start-DscConfiguration cmdlet is called or when the Test-DscConfiguration cmdlet is called.
This script block should return a boolean with |
|
Credential |
PSCredential |
The credential of the user account to run the script under if needed. |
Scripts:
Items:
- Name: JeaDiscovery.psd1
GetScript: |
@{
Result = (Get-Date)
}
TestScript: |
[bool](Get-Date)
SetScript: |
Get-Date
- Name: ParamTestScript
Params:
a: 1
b: Test
c:
- x: 1
y: 2
z: 3
TestScript: |
Write-Verbose 'Param a: ' + $params.a
Write-Verbose 'Param c.x: ' + $params.c.x
[bool](Get-Date)