@@ -16,12 +16,12 @@ function Push-UploadApplication {
1616
1717 $ChocoApp = (Get-CIPPAzDataTableEntity @Table - filter $Filter ).JSON | ConvertFrom-Json
1818 $intuneBody = $ChocoApp.IntuneBody
19- $tenants = if ($chocoapp .Tenant -eq ' AllTenants' ) {
20- (Get-tenants ).defaultDomainName
19+ $tenants = if ($ChocoApp .tenant -eq ' AllTenants' ) {
20+ (Get-Tenants - IncludeErrors ).defaultDomainName
2121 } else {
22- $chocoapp .Tenant
22+ $ChocoApp .tenant
2323 }
24- if ($chocoApp .type -eq ' MSPApp' ) {
24+ if ($ChocoApp .type -eq ' MSPApp' ) {
2525 [xml ]$Intunexml = Get-Content " AddMSPApp\$ ( $ChocoApp.MSPAppName ) .app.xml"
2626 $intunewinFilesize = (Get-Item " AddMSPApp\$ ( $ChocoApp.MSPAppName ) .intunewin" )
2727 $Infile = " AddMSPApp\$ ( $ChocoApp.MSPAppName ) .intunewin"
@@ -30,7 +30,7 @@ function Push-UploadApplication {
3030 $intunewinFilesize = (Get-Item ' AddChocoApp\IntunePackage.intunewin' )
3131 $Infile = " AddChocoApp\$ ( $intunexml.ApplicationInfo.FileName ) "
3232 }
33- $assignTo = $ChocoApp.AssignTo
33+ $assignTo = $ChocoApp.assignTo
3434 $AssignToIntent = $ChocoApp.InstallationIntent
3535 $Baseuri = ' https://graph.microsoft.com/beta/deviceAppManagement/mobileApps'
3636 $ContentBody = ConvertTo-Json @ {
@@ -39,7 +39,7 @@ function Push-UploadApplication {
3939 sizeEncrypted = [int64 ]($intunewinFilesize ).length
4040 }
4141 $ClearRow = Get-CIPPAzDataTableEntity @Table - Filter $Filter
42- $RemoveCacheFile = if ($chocoapp .Tenant -ne ' AllTenants' ) {
42+ $RemoveCacheFile = if ($ChocoApp .tenant -ne ' AllTenants' ) {
4343 Remove-AzDataTableEntity - Force @Table - Entity $clearRow
4444 } else {
4545 $Table.Force = $true
@@ -63,24 +63,24 @@ function Push-UploadApplication {
6363 } | ConvertTo-Json
6464
6565 foreach ($tenant in $tenants ) {
66- Try {
67- $ApplicationList = (New-graphGetRequest - Uri $baseuri - tenantid $Tenant ) | Where-Object { $_.DisplayName -eq $ChocoApp.ApplicationName }
66+ try {
67+ $ApplicationList = (New-GraphGetRequest - Uri $baseuri - tenantid $tenant ) | Where-Object { $_.DisplayName -eq $ChocoApp.Applicationname }
6868 if ($ApplicationList.displayname.count -ge 1 ) {
69- Write-LogMessage - api ' AppUpload' - tenant $ ( $Tenant ) - message " $ ( $ChocoApp.ApplicationName ) exists. Skipping this application" - Sev ' Info'
69+ Write-LogMessage - api ' AppUpload' - tenant $tenant - message " $ ( $ChocoApp.Applicationname ) exists. Skipping this application" - Sev ' Info'
7070 continue
7171 }
72- if ($chocoApp .type -eq ' WinGet' ) {
72+ if ($ChocoApp .type -eq ' WinGet' ) {
7373 Write-Host ' Winget!'
7474 Write-Host ($intuneBody | ConvertTo-Json - Compress)
7575 $NewApp = New-GraphPostRequest - Uri $baseuri - Body ($intuneBody | ConvertTo-Json - Compress) - Type POST - tenantid $tenant
7676 Start-Sleep - Milliseconds 200
77- Write-LogMessage - api ' AppUpload' - tenant $ ( $Tenant ) - message " $ ( $ChocoApp.ApplicationName ) uploaded as WinGet app." - Sev ' Info'
77+ Write-LogMessage - api ' AppUpload' - tenant $tenant - message " $ ( $ChocoApp.Applicationname ) uploaded as WinGet app." - Sev ' Info'
7878 if ($AssignTo -ne ' On' ) {
7979 $intent = if ($AssignToIntent ) { ' Uninstall' } else { ' Required' }
8080 Set-CIPPAssignedApplication - ApplicationId $NewApp.Id - Intent $intent - TenantFilter $tenant - groupName " $AssignTo " - AppType ' WinGet'
8181 }
82- Write-LogMessage - api ' AppUpload' - tenant $ ( $Tenant ) - message " $ ( $ChocoApp.ApplicationName ) Successfully created" - Sev ' Info'
83- exit 0
82+ Write-LogMessage - api ' AppUpload' - tenant $tenant - message " $ ( $ChocoApp.Applicationname ) Successfully created" - Sev ' Info'
83+ continue
8484 } else {
8585 $NewApp = New-GraphPostRequest - Uri $baseuri - Body ($intuneBody | ConvertTo-Json ) - Type POST - tenantid $tenant
8686
@@ -109,23 +109,23 @@ function Push-UploadApplication {
109109 $CommitStateReq = New-graphGetRequest - Uri " $ ( $BaseURI ) /$ ( $NewApp.id ) /microsoft.graph.win32lobapp/contentVersions/1/files/$ ( $ContentReq.id ) " - tenantid $tenant
110110 Write-Host " Commit State Request: $ ( $CommitStateReq | ConvertTo-Json - Depth 10 ) "
111111 if ($CommitStateReq.uploadState -like ' *fail*' ) {
112- Write-LogMessage - api ' AppUpload' - tenant $ ( $Tenant ) - message " $ ( $ChocoApp.ApplicationName ) Commit failed. Please check if app uploaded succesful" - Sev ' Warning'
112+ Write-LogMessage - api ' AppUpload' - tenant $tenant - message " $ ( $ChocoApp.Applicationname ) Commit failed. Please check if app uploaded succesful" - Sev ' Warning'
113113 break
114114 }
115115 Start-Sleep - Milliseconds 300
116116 } while ($CommitStateReq.uploadState -eq ' commitFilePending' )
117117 $CommitFinalizeReq = New-graphPostRequest - Uri " $ ( $BaseURI ) /$ ( $NewApp.id ) " - tenantid $tenant - Body ' {"@odata.type":"#microsoft.graph.win32lobapp","committedContentVersion":"1"}' - type PATCH
118118 Write-Host " Commit Finalize Request: $ ( $CommitFinalizeReq | ConvertTo-Json - Depth 10 ) "
119- Write-LogMessage - api ' AppUpload' - tenant $ ( $Tenant ) - message " Added Application $ ( $chocoApp .ApplicationName ) " - Sev ' Info'
119+ Write-LogMessage - api ' AppUpload' - tenant $tenant - message " Added Application $ ( $ChocoApp .Applicationname ) " - Sev ' Info'
120120 if ($AssignTo -ne ' On' ) {
121121 $intent = if ($AssignToIntent ) { ' Uninstall' } else { ' Required' }
122122 Set-CIPPAssignedApplication - ApplicationId $NewApp.Id - Intent $intent - TenantFilter $tenant - groupName " $AssignTo " - AppType ' Win32Lob'
123123
124124 }
125- Write-LogMessage - api ' AppUpload' - tenant $ ( $Tenant ) - message ' Successfully added Application' - Sev ' Info'
125+ Write-LogMessage - api ' AppUpload' - tenant $tenant - message ' Successfully added Application' - Sev ' Info'
126126 } catch {
127127 " Failed to add Application for $ ( $Tenant ) : $ ( $_.Exception.Message ) "
128- Write-LogMessage - api ' AppUpload' - tenant $ ( $Tenant ) - message " Failed adding Application $ ( $ChocoApp.ApplicationName ) . Error: $ ( $_.Exception.Message ) " - LogData (Get-CippException - Exception $_ ) - Sev ' Error'
128+ Write-LogMessage - api ' AppUpload' - tenant $tenant - message " Failed adding Application $ ( $ChocoApp.Applicationname ) . Error: $ ( $_.Exception.Message ) " - LogData (Get-CippException - Exception $_ ) - Sev ' Error'
129129 continue
130130 }
131131 }
0 commit comments