Classes/IntuneApp.psm1

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
class IntuneApp {
    [string]$ApplicationId
    [string]$Url
    [string]$Key
    [string]$IV
    [string]$BinFileName
    [system.io.FileInfo]$DownloadPath

    IntuneApp( [string]$ApplicationId, 
        [PSCustomObject]$contentInfo, 
        [PSCustomObject]$decryptInfo, 
        [system.io.FileInfo]$downloadPath ) {

        $this.ApplicationId = $applicationId
        $this.Url = $contentInfo.UploadLocation
        $this.Key = $decryptInfo.EncryptionKey
        $this.IV = $decryptInfo.IV
        $this.BinFileName = $(Split-Path $this.Url -Leaf)
        $this.DownloadPath = "$downloadPath\$applicationId"
    }
}

class IntuneApps {
    [System.Collections.ArrayList]$applications
    IntuneApps() {
        $this.applications = [System.Collections.ArrayList]::new()
    }
    Add( [string]$applicationId, 
        [PSCustomObject]$contentInfo, 
        [PSCustomObject]$decryptInfo, 
        [system.io.FileInfo]$downloadPath ) {
        if ($applicationId -notin $this.applications.ApplicationId) {
            $intuneApp = [IntuneApp]::new($applicationId, $contentInfo, $decryptInfo, $downloadPath)
            $this.applications.Add($intuneApp)
            New-Event -SourceIdentifier 'IME.AppFound' -MessageData $intuneApp
        }
    }
}