forked from microsoftgraph/powershell-intune-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Win32_Application_Add_Example.ps1
49 lines (32 loc) · 1.63 KB
/
Win32_Application_Add_Example.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
####################################################
Test-AuthToken
####################################################
$baseUrl = "https://graph.microsoft.com/beta/deviceAppManagement/"
$logRequestUris = $true;
$logHeaders = $false;
$logContent = $true;
$azureStorageUploadChunkSizeInMb = 6l;
$sleep = 30
####################################################
# Sample Win32 Application
####################################################
$SourceFile = "C:\packages\package.intunewin"
# Defining Intunewin32 detectionRules
$DetectionXML = Get-IntuneWinXML "$SourceFile" -fileName "detection.xml"
# Defining Intunewin32 detectionRules
$FileRule = New-DetectionRule -File -Path "C:\Program Files\Application" `
-FileOrFolderName "application.exe" -FileDetectionType exists -check32BitOn64System False
$RegistryRule = New-DetectionRule -Registry -RegistryKeyPath "HKEY_LOCAL_MACHINE\SOFTWARE\Program" `
-RegistryDetectionType exists -check32BitRegOn64System True
$MSIRule = New-DetectionRule -MSI -MSIproductCode $DetectionXML.ApplicationInfo.MsiInfo.MsiProductCode
# Creating Array for detection Rule
$DetectionRule = @($FileRule,$RegistryRule,$MSIRule)
$ReturnCodes = Get-DefaultReturnCodes
$ReturnCodes += New-ReturnCode -returnCode 302 -type softReboot
$ReturnCodes += New-ReturnCode -returnCode 145 -type hardReboot
# Win32 Application Upload
Upload-Win32Lob -SourceFile "$SourceFile" -publisher "Publisher" `
-description "Description" -detectionRules $DetectionRule -returnCodes $ReturnCodes `
-installCmdLine "powershell.exe .\install.ps1" `
-uninstallCmdLine "powershell.exe .\uninstall.ps1"
####################################################