Syntax error in RemoveModernApp()

This commit is contained in:
Yorick Barbanneau 2018-04-10 17:16:19 +02:00
parent 1739c2f800
commit 5536ab63b3
2 changed files with 10 additions and 10 deletions

View file

@ -416,12 +416,12 @@ function UninstallModernApp {
Write-Host -ForegroundColor Red "`tError : No name or file for action $($MyInvocation.MyCommand.Name)" Write-Host -ForegroundColor Red "`tError : No name or file for action $($MyInvocation.MyCommand.Name)"
return return
} }
if ( $params.ContainsKey('removeProvisionned' ) ) { if ( $params.ContainsKey('removeProvisioned') -and $params.removeProvisioned -eq $true ) {
UninstallModernProvisonnedApp $params UninstallModernProvisionedApp $params
} }
} }
function UninstallModernProvisonnedApp { function UninstallModernProvisionedApp {
param( param(
[cmdletbinding( [cmdletbinding(
DefaultParameterSetName='params' DefaultParameterSetName='params'
@ -438,14 +438,14 @@ function UninstallModernProvisonnedApp {
$pkgs = $(Get-AppxProvisionedPackage -Online).DisplayName $pkgs = $(Get-AppxProvisionedPackage -Online).DisplayName
$list = Get-Content $params.file | Where { $_ -notmatch "^#.*$|^$" } $list = Get-Content $params.file | Where { $_ -notmatch "^#.*$|^$" }
$pkgs | Where-Object { $_ -in $list } | Foreach { $pkgs | Where-Object { $_ -in $list } | Foreach {
UninstallModernProvisonnedApp @{name=$_} UninstallModernProvisionedApp @{name=$_}
} }
$list | Where-Object { $_ -notin $pkgs } | Foreach { $list | Where-Object { $_ -notin $pkgs } | Foreach {
Write-Host -ForegroundColor Yellow "`tProvisionned App $_ not found" Write-Host -ForegroundColor Yellow "`tProvisioned App $_ not found"
} }
} }
elseif ( $params.ContainsKey('name') ){ elseif ( $params.ContainsKey('name') ){
Write-Host -NoNewLine "`tUninstall Provisonned $($params.name) :" Write-Host -NoNewLine "`tUninstall Provisioned $($params.name) :"
try { try {
$(Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -eq $($params.name) }) | Remove-AppxProvisionedPackage -Online | Out-Null $(Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -eq $($params.name) }) | Remove-AppxProvisionedPackage -Online | Out-Null
Write-Host -ForegroundColor Green "done" Write-Host -ForegroundColor Green "done"

View file

@ -12,7 +12,7 @@
"_comment" : "Uninstall Windows Maps", "_comment" : "Uninstall Windows Maps",
"action" : "UninstallModernApp", "action" : "UninstallModernApp",
"name" : "Microsoft.WindowsMaps", "name" : "Microsoft.WindowsMaps",
"removeProvisonned" : "True" "removeProvisioned" : true
}, },
{ {
"_comment" : "Disable xbox services for uninstall Apps", "_comment" : "Disable xbox services for uninstall Apps",
@ -35,19 +35,19 @@
"_comment" : "Uninstall Xbox Apps", "_comment" : "Uninstall Xbox Apps",
"action" : "UninstallModernApp", "action" : "UninstallModernApp",
"file" : "XboxApps.txt", "file" : "XboxApps.txt",
"removeProvisonned" : "True" "removeProvisioned" : true
}, },
{ {
"_comment" : "Uninstall Microsoft Apps", "_comment" : "Uninstall Microsoft Apps",
"action" : "UninstallModernApp", "action" : "UninstallModernApp",
"file" : "MicrosoftApps.txt", "file" : "MicrosoftApps.txt",
"removeProvisionned" : "True" "removeProvisioned" : true
}, },
{ {
"_comment" : "Uninstall third party apps", "_comment" : "Uninstall third party apps",
"action" : "UninstallModernApp", "action" : "UninstallModernApp",
"file" : "OthersApps.txt", "file" : "OthersApps.txt",
"removeProvisionned" : "True" "removeProvisioned" : true
} }
] ]
} }