salt-states/removeAppXPackages.sls

29 lines
1.0 KiB
Plaintext
Raw Normal View History

{% import_yaml "badAppXPackages.yaml" as packages %}
{#
# {% for pkg in packages %}
# Remove {{ pkg }}:
# cmd.run:
# - names:
# - Get-AppxPackage -AllUsers {{pkg}} | Remove-AppxPackage
# - Get-AppxProvisionedPackage -Online | where-object DisplayName -eq "{{pkg}}" | Remove-AppxProvisionedPackage -Online
# - shell: powershell
# {% endfor %}
#}
{% set installed_packages = salt['cmd.powershell']('(Get-AppxPackage -AllUsers).Name') %}
{% for pkg in packages|intersect(installed_packages) %}
Remove {{ pkg }}:
cmd.run:
- name: Get-AppxPackage -AllUsers {{pkg}} | Remove-AppxPackage
- shell: powershell
{% endfor %}
{% set provisioned_packages = salt['cmd.powershell']('(Get-AppxProvisionedPackage -Online).DisplayName') %}
{% for pkg in packages|intersect(provisioned_packages) %}
Remove provisioned {{ pkg }}:
cmd.run:
- name: Get-AppxProvisionedPackage -Online | where-object DisplayName -eq "{{pkg}}" | Remove-AppxProvisionedPackage -Online
- shell: powershell
{% endfor %}