From 42439e1e69283977871f5a647528cad505ed77b6 Mon Sep 17 00:00:00 2001 From: Benjamin TESTART <114827544+Benjamin-Testart@users.noreply.github.com> Date: Sat, 1 Oct 2022 20:16:01 +0200 Subject: [PATCH] Add foreach for remove multiple app --- Applications/Application_MDM_Remove.ps1 | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Applications/Application_MDM_Remove.ps1 b/Applications/Application_MDM_Remove.ps1 index cc9cf86..12a8bd2 100644 --- a/Applications/Application_MDM_Remove.ps1 +++ b/Applications/Application_MDM_Remove.ps1 @@ -326,15 +326,24 @@ $global:authToken = Get-AuthToken -User $User #################################################### -$App = Get-IntuneApplication -Name "Microsoft Excel" +# One App +# $App = Get-IntuneApplication -Name "Microsoft Excel" + +# Multiple Apps +$App = Get-IntuneApplication if($App){ if(@($App).count -gt 1){ - - Write-Host "More than one application has been found, please specify a single application..." -ForegroundColor Red - Write-Host - + foreach ($Object in $App) { + if ($Object.displayName -ne "Company Portal") { + write-host "Removing Application..." -f Yellow + $Object.displayname + ": " + $Object.'@odata.type' + $Object.id + Remove-IntuneApplication -id $Object.id + write-host + } + } } elseif(@($App).count -eq 1){