Seite 1 von 1
Windows Apps entfernen - powershell elevated
Verfasst: 02 Apr 2020, 11:02
von g.burck
Moin,
ich möchte gerne über einen Powershell Aufruf gezielt Windows Apps deinstallieren z.B.:
Code: Alles auswählen
Get-appxprovisionedpackage –online | where-object {$_.packagename –like “*Microsoft.Officehub*”} | Remove-AppxProvisionedPackage -online
Wenn ich es richtig verstanden habe muss ich über ein elevated Winbatch die Powershell ansprechen?
Grüße
Gregor
Re: Windows Apps entfernen - powershell elevated
Verfasst: 02 Apr 2020, 11:09
von m.radtke
Hi Gegor,
seit einiger Zeit gibt es denn "
powershellCall()"
Gruß
Mathias
Re: Windows Apps entfernen - powershell elevated
Verfasst: 02 Apr 2020, 11:54
von g.burck
Danke schon mal.
Läuft das automatisch elevated?
Re: Windows Apps entfernen - powershell elevated
Verfasst: 02 Apr 2020, 14:03
von g.burck
Fast gelöst: der Aufruf
Code: Alles auswählen
powershellCall('Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*Microsoft.Officehub*"} | Remove-AppxProvisionedPackage -online')
Löscht brav die App. Jetzt habe ich in der Control Datei eine Property definiert:
Code: Alles auswählen
[ProductProperty]
type: bool
name: microsoft.officehub
description: Entfernt die Office 365 App
default: True
Jetzt eine ganz blöde Frage, wie werte ich die mit if auf true aus?
Code: Alles auswählen
[Actions]
requiredWinstVersion >= "4.10.8.6"
DefVar $MicrosoftOfficehub$
Set $MicrosoftOfficehub$ = GetProductProperty("Microsoft.Officehub","")
if $MicrosoftOfficehub$ =true
powershellCall('Get-appxprovisionedpackage -online | where-object {$_.packagename -like "*Microsoft.Officehub*"} | Remove-AppxProvisionedPackage -online')
endif
Re: Windows Apps entfernen - powershell elevated
Verfasst: 02 Apr 2020, 15:47
von g.burck
Re: Windows Apps entfernen - powershell elevated
Verfasst: 08 Apr 2020, 12:11
von SisterOfMercy
Code: Alles auswählen
DefVar $MicrosoftOfficehub$
Set $MicrosoftOfficehub$ = GetProductProperty("Microsoft.Officehub","true")
if $MicrosoftOfficehub$ = "true"
powershellCall('Get-ProvisionedAppxPackage -online | Where-Object {$_.DisplayName -like "*Microsoft.Officehub*"} | Remove-AppxProvisionedPackage -Online -AllUsers')
endif
I've changed it a bit. Now the default value for the productproperty is true. (which is used if it is not defined in the control file, or if it runs locally, without connection to the opsi server). Also the -AllUsers thing is something you might want.
Re: Windows Apps entfernen - powershell elevated
Verfasst: 10 Apr 2020, 11:48
von feltel
Du kannst auf Produkt-Properties im Code auch direkt ohne dem Umweg einer Variablenzuweisung zugreifen. Beispiel:
Code: Alles auswählen
if GetProductProperty("install_with_desktop_icon", "False") = "False"
LinkFolder_Delete_Desktop_Icon
endif