-
Notifications
You must be signed in to change notification settings - Fork 10
/
Package-IntuneApp.ps1
47 lines (38 loc) · 1.43 KB
/
Package-IntuneApp.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
[CmdletBinding()]
param
(
[ValidateNotNullOrEmpty()]
[parameter(Mandatory=$True)]
[String]$SourceFolder,
[ValidateNotNullOrEmpty()]
[parameter(Mandatory=$True)]
[String]$SetupFile,
[ValidateNotNullOrEmpty()]
[parameter(Mandatory=$False)]
[String]$OutPutFolder = "$(Split-path -Path $SourceFolder -Parent)\_Output\$(Split-path -Path $SourceFolder -Leaf)"
)
If ( -not (test-path -Path $SourceFolder)){
throw "Cannot find sourcefolder: [$SourceFolder]"
return
}
If ( -not (test-path -Path "$SourceFolder\$SetupFile")){
throw "Cannot find setupfile: [$SetupFile]"
return
}
If ( -not (test-path -Path $OutPutFolder)){
New-Item -Path $OutPutFolder -ItemType Directory -Force | Out-Null
}
If (-not (test-path -Path "$PSScriptRoot\IntuneWinAppUtil.exe")){
throw "Cannot find IntuneWinAppUtil.exe at: [$PSScriptRoot]"
return
}
Start-Process -FilePath "$PSScriptRoot\IntuneWinAppUtil.exe" -ArgumentList "-c $SourceFolder -s $SetupFile -o $OutPutFolder -q" -Wait
$SetupFilePath = (get-item -Path "$SourceFolder\$SetupFile").FullName
$fileNameOnly = [System.IO.Path]::GetFileNameWithoutExtension($SetupFilePath)
$intunewinfile = $("$fileNameOnly.intunewin")
If ( Test-Path -Path "$OutPutFolder\$intunewinfile" ) {
Write-output -InputObject "[$intunewinfile] file succesfully created"
} else {
throw "File [$intunewinfile] not created"
return
}