Examples/Test_Sample_xArchive_CompressMultipleDirs.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
$zipFilePath = "$pwd\Target.zip"

del "$pwd\SourceDir-1" -Force -Recurse -ErrorAction SilentlyContinue
del "$pwd\SourceDir-2" -Force -Recurse -ErrorAction SilentlyContinue


New-Item $pwd\SourceDir-1 -Type Directory | Out-Null
New-Item $pwd\SourceDir-1\Sample-1.txt -Type File | Out-Null
New-Item $pwd\SourceDir-1\Sample-2.txt -Type File | Out-Null

New-Item $pwd\SourceDir-2 -Type Directory | Out-Null
New-Item $pwd\SourceDir-2\Sample-1.txt -Type File | Out-Null
New-Item $pwd\SourceDir-2\Sample-2.txt -Type File | Out-Null

$sourceFilePath = @("$pwd\SourceDir-1", "$pwd\SourceDir-2")


Configuration Sample_xArchive_CompressMultipleDirs
{
    Import-DscResource -ModuleName xPSDesiredStateConfiguration
    Node localhost
    {
        xArchive SampleCompressMultipleDirsArchive
        {
            Path = $sourceFilePath
            Destination = $zipFilePath
            CompressionLevel = "Optimal"
            DestinationType="File"
            MatchSource=$true
        }
    }
}

Sample_xArchive_CompressMultipleDirs