Скрипт Powershell, поставляемый через SCCM 2012, для полного удаления приложений Windows 8.1

1836
mcbla

Я ищу руководство по выполнению вышеуказанной задачи.

Мой скрипт Powershell, как показано ниже, в настоящее время удаляет одно конкретное приложение с именем.

$AppsToDelete="*Microsoft.WindowsReadingList*" Foreach ($AppName in $AppsToDelete) { get-appxprovisionedpackage -online | where packagename -like $AppName | remove-appxprovisionedpackage -Online Get-AppxPackage -name $AppName -allusers | Remove-AppxPackage } 

Программа, используемая SCCM2012 для выполнения скрипта, выглядит следующим образом:

PowerShell.exe -ExecutionPolicy UnRestricted -File .\delappsreadinglistonly.ps1 

Я создал программу в SCCM 2012 и развернул ее на клиенте.

Программа настроена на запуск от имени пользователя, а не системы,

Файл EXECMGR.log сообщает мне, что скрипт получен клиентом и успешно запущен, код выхода = 0, статус выполнения - Успешно.

Тем не менее, плитка «Список чтения» все еще находится на начальном экране (Metro?), Приложение «Список чтения» по-прежнему отображается в алфавитном списке «Приложения по имени» и может быть выполнено, а различные папки по-прежнему существуют в C: \ program files \ windowsapps \

Указатели будут оценены.

1
Я знаю, что это может быть глупым комментарием, но я укажу, что если машина все еще находится в коллекции SCCM, чтобы получить это приложение, приложение будет просто переустановлено после его удаления. EBGreen 8 лет назад 1
Здравствуйте, спасибо за ваш комментарий. Во избежание сомнений, «приложения», которые я хочу удалить, - это различные «приложения», встроенные в ОС Windows 8.1 и видимые в виде плиток на начальном экране Metro. Я считаю, что такие «приложения» известны как .appx. Они не являются приложениями, как доставлено с использованием метода в SSCM 2012. Извините за путаницу. Благодарю. mcbla 8 лет назад 0

1 ответ на вопрос

1
alx9r

I see two potential problems with your script:

  1. The calls to -AppxProvisionedPackage most likely require elevation. When you run your script as a user it probably throws an exception.
  2. The call to Get-AppxPackage -allusers requires administrator permissions. The documentation for -allusers reads "to use this parameter, you must run the command by using administrator permissions."

It's not clear to me exactly what your goal is. Here is how I deal with the mess of tiles in the Windows 8.1 start screen:

  • Create an SCCM Application with the following characteristics:
    • no installer
    • uninstaller that calls Remove-AppxPackage for a list of common apps
    • detection script for that list of apps
  • Deploy the Application with the Uninstall Action to the affected users.

I use this strategy because it sets things up to be more surgical with which of those apps is available to specific users in the future if that turns out to be necessary.

When a user to which this Application is deployed for removal is logged in, CcmExec eventually detects the application and invokes the uninstall command. After the uninstall command is invoked the applications should no longer be visible or available to the user.

Uninstall-Application.ps1

Here is the body of the uninstall script I use. You need to be careful about how you set up PowerShell scripts that are invoked for (un)installation because exit codes are a bit tricky to get from the script reliably.

$appList = 'Microsoft.BingSports', # ...longlist of other apps... 'Microsoft.WindowsReadingList' Get-AppxPackage | ? { $_.Name -in $appList } | % { Remove-AppxPackage $_.PackageFullName } 

Detect-Application.ps1

Below is the body of the detection script I use. Note that there are some pitfalls to using PowerShell detection scripts:

If you do all that PowerShell detection scripts work beautifully for complicated, surgical, or unconventional detection like this.

 $appList = 'Microsoft.BingSports', # ...longlist of other apps... 'Microsoft.WindowsReadingList' Get-AppxPackage | ? { $_.Name -in $appList } 
alx9r, спасибо за указатели, очень подробный. Я сделаю это в свое время. Я был далеко отсюда поздний ответ. Еще раз спасибо mcbla 8 лет назад 0