configs/SampleConfigWithScriptResource.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
configuration ScriptResourceSample {
    Import-DscResource -ModuleName PSDesiredStateConfiguration
    
    Node 'localhost' {   
        #Disables RDP
        Script 'ScriptResourceOne' {
            GetScript = {
                @{
                    Results = (Get-NetFirewallRule -DisplayGroup 'Remote Desktop').Enabled
                } #Returns a HashTable @{}
            }
            TestScript = {
                ((Get-NetFirewallRule -DisplayGroup 'Remote Desktop').Enabled).Contains('False') #Returns True or False
            }
            SetScript = {
                Set-NetFirewallRule -DisplayGroup 'Remote Desktop' -Enabled True #Makes it so!
            }
        }
    }    
}

ScriptResourceSample -OutputPath .\