Skip to content

Commit 5a162db

Browse files
authored
Merge pull request #385 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents b2b4a4f + 15cd3bb commit 5a162db

File tree

6 files changed

+104
-14
lines changed

6 files changed

+104
-14
lines changed

AddMSPApp/datto.app.xml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
<ApplicationInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ToolVersion="1.8.3.0">
2-
<Name>install.ps1</Name>
3-
<UnencryptedContentSize>705</UnencryptedContentSize>
4-
<FileName>datto.intunewin</FileName>
5-
<SetupFile>install.ps1</SetupFile>
6-
<EncryptionInfo>
7-
<EncryptionKey>sL/LP/JZ4F4cBSykm6usgJoV1PMoqd62C6JUwuo2z24=</EncryptionKey>
8-
<MacKey>PEpeqeoX7jAWxb0xHGfCkKFxh4/YRfoMTVXrP+uZWzM=</MacKey>
9-
<InitializationVector>ulFPA+vYjaxX0pvq0BMAKQ==</InitializationVector>
10-
<Mac>28ZFU4AT1OznwF8pfqO8i+WFUNSf9024H4Jw2H7UJWs=</Mac>
11-
<ProfileIdentifier>ProfileVersion1</ProfileIdentifier>
12-
<FileDigest>YEb+QNQCko/uZyedA+JfcP/RDm+nZOIjFN04CfhwN4c=</FileDigest>
13-
<FileDigestAlgorithm>SHA256</FileDigestAlgorithm>
14-
</EncryptionInfo>
1+
<ApplicationInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ToolVersion="1.8.3.0">
2+
<Name>install.ps1</Name>
3+
<UnencryptedContentSize>693</UnencryptedContentSize>
4+
<FileName>datto.intunewin</FileName>
5+
<SetupFile>install.ps1</SetupFile>
6+
<EncryptionInfo>
7+
<EncryptionKey>jobB9Ga7J3CbO6acWJyvBRE56nFXwqGfcnGfZRMsJC4=</EncryptionKey>
8+
<MacKey>53SOzs0l6Po2btsGFSMZgkV8vwhH+PxTN8BZDUcfWfg=</MacKey>
9+
<InitializationVector>VjM/osrvPElbu79J+mdXuw==</InitializationVector>
10+
<Mac>UZZXO53Np/tG6Ms+qvwLcNOeD1GRH6NRPFg/TuMz39M=</Mac>
11+
<ProfileIdentifier>ProfileVersion1</ProfileIdentifier>
12+
<FileDigest>KtAWAl29064LG0eyDinbDs0JUbK+EK7GsJovu8obBM4=</FileDigest>
13+
<FileDigestAlgorithm>SHA256</FileDigestAlgorithm>
14+
</EncryptionInfo>
1515
</ApplicationInfo>

AddMSPApp/datto.intunewin

-16 Bytes
Binary file not shown.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
param(
2+
$PackagePath,
3+
$MetadataPath
4+
)
5+
6+
# Example: .\tools\IntuneWin\Get-IntuneWinPackageContents.ps1 -PackagePath .\AddMSPApp\datto.intunewin -MetadataPath .\AddMSPApp\datto.app.xml
7+
8+
$Metadata = [xml](Get-Content -Path $MetadataPath)
9+
$Encryption = $Metadata.ApplicationInfo.EncryptionInfo
10+
11+
$Package = Get-Item $PackagePath
12+
13+
Write-Host "Decrypting IntuneWin package $($Package.FullName)"
14+
Write-Host "Using encryption key: $($Encryption.EncryptionKey)"
15+
Write-Host "Using initialization vector: $($Encryption.InitializationVector)"
16+
17+
$DecoderParams = @(
18+
"`"$($Package.FullName)`""
19+
"/key:`"$($Encryption.EncryptionKey)`""
20+
"/iv:`"$($Encryption.InitializationVector)`""
21+
)
22+
23+
Start-Process -FilePath "$PSScriptRoot\IntuneWinAppUtilDecoder.exe" -ArgumentList $DecoderParams -Wait -NoNewWindow
24+
# replace filename.intunewin with filename.decoded.zip
25+
$NewFileName = "$($Package.BaseName -replace '\.intunewin$', '').decoded.zip"
26+
27+
#Extract zip
28+
Write-Host "Extracting decrypted IntuneWin package: $($Package.DirectoryName)\$NewFileName"
29+
Expand-Archive -Path "$($Package.DirectoryName)\$NewFileName" -DestinationPath "$($Package.DirectoryName)\$($Package.BaseName)" -Force
30+
31+
# Remove the decoded zip file
32+
Remove-Item -Path "$($Package.DirectoryName)\$NewFileName" -Force
File renamed without changes.
12.5 KB
Binary file not shown.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
param(
2+
[Parameter(Mandatory = $true)]
3+
[string]$SourcePath,
4+
[Parameter(Mandatory = $true)]
5+
[string]$FileName,
6+
[Parameter(Mandatory = $true)]
7+
[string]$MetadataFileName
8+
)
9+
10+
# Example: .\Tools\IntuneWin\New-IntuneWinPackage.ps1 -SourcePath .\AddMSPApp\datto\ -FileName datto.intunewin -MetadataFileName datto.app.xml
11+
12+
$Source = Get-Item -Path $SourcePath
13+
14+
$Params = @(
15+
"-c $SourcePath"
16+
'-s install.ps1'
17+
"-o $SourcePath"
18+
'-q'
19+
)
20+
21+
Start-Process -FilePath "$PSScriptRoot\IntuneWinAppUtil.exe" -ArgumentList $Params -Wait -NoNewWindow
22+
23+
Expand-Archive -Path "$SourcePath\install.intunewin" -DestinationPath $SourcePath -Force
24+
Write-Host "IntuneWin package contents extracted to: $SourcePath"
25+
Remove-Item -Path "$SourcePath\install.intunewin" -Force
26+
Write-Host "Temporary IntuneWin package file removed from: $SourcePath\install.intunewin"
27+
28+
# Extract IntunePackage.intunewin from Contents and move to the parent directory
29+
$IntunePackagePath = Join-Path $SourcePath 'IntuneWinPackage\Contents\IntunePackage.intunewin'
30+
if (Test-Path -Path $IntunePackagePath) {
31+
Move-Item -Path $IntunePackagePath -Destination (Join-Path $Source.Parent.FullName $FileName) -Force
32+
Write-Host "IntunePackage.intunewin moved to: $($Source.Parent.FullName)\$FileName"
33+
} else {
34+
Write-Host 'IntunePackage.intunewin not found in Contents directory.'
35+
}
36+
37+
# Copy the Metadata/Detection.xml file to the parent directory
38+
$DetectionFilePath = Join-Path $SourcePath 'IntuneWinPackage\Metadata\Detection.xml'
39+
40+
if (Test-Path -Path $DetectionFilePath) {
41+
$MetadataXml = [xml](Get-Content -Path $DetectionFilePath)
42+
$MetadataXml.ApplicationInfo.FileName = $FileName
43+
$MetadataXml.Save($DetectionFilePath)
44+
Write-Host "Detection.xml updated with FileName: $FileName"
45+
} else {
46+
Write-Host 'Detection.xml not found in Metadata directory.'
47+
}
48+
49+
if (Test-Path -Path $DetectionFilePath) {
50+
Copy-Item -Path $DetectionFilePath -Destination (Join-Path $Source.Parent.FullName $MetadataFileName) -Force
51+
Write-Host "Detection.xml copied to: $($Source.Parent.FullName)\$MetadataFileName"
52+
} else {
53+
Write-Host 'Detection.xml not found in Metadata directory.'
54+
}
55+
56+
# Clean up the Source directory
57+
Remove-Item -Path $SourcePath -Recurse -Force
58+
Write-Host "Temporary files cleaned up from: $SourcePath"

0 commit comments

Comments
 (0)