Examples/Sample_cFirewall.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

configuration Sample_cFirewall
{
    Import-DscResource -ModuleName cFirewall

    cFirewallRule FirewallRule1
    {
        Name = 'Allow Custom Rule'
        Action = 'Allow'
        Description = 'Created by the cFirewallRule DSC resource.'
        Direction = 'Inbound'
        Enabled = $true
        Ensure = 'Present'
        Group = 'DSC'
        LocalPort = '6465', '6500-6520'
        RemoteAddress = '192.168.0.10-192.168.0.20', '192.168.1.0/24', '192.168.2.10'
        Profile = 'Domain', 'Private'
        Protocol = 'TCP'
    }

    cFirewallRule FirewallRule2
    {
        Name = 'Allow Inbound HTTP Traffic'
        Action = 'Allow'
        Description = 'Created by the cFirewallRule DSC resource.'
        Direction = 'Inbound'
        Enabled = $true
        Ensure = 'Present'
        Group = 'DSC'
        LocalPort = '80'
        Profile = 'All'
        Protocol = 'TCP'
    }

    cFirewallRule FirewallRule3
    {
        Name = 'Block Outbound HTTP Traffic'
        Action = 'Block'
        Description = 'Created by the cFirewallRule DSC resource.'
        Direction = 'Outbound'
        Enabled = $true
        Ensure = 'Present'
        Group = 'DSC'
        LocalPort = '80'
        Profile = 'All'
        Protocol = 'TCP'
    }

}

Sample_cFirewall -OutputPath "$Env:SystemDrive\Sample_cFirewall"

Start-DscConfiguration -Path "$Env:SystemDrive\Sample_cFirewall" -Force -Verbose -Wait

Get-DscConfiguration