g.burck
Beiträge: 228 Registriert: 23 Mai 2018, 16:44
Beitrag
von g.burck » 02 Apr 2020, 11:02
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
Zuletzt geändert von
g.burck am 02 Apr 2020, 14:00, insgesamt 2-mal geändert.
opsi config editor Version 4.1.9.8.5 (2021/04/12)
opsiconfd 4.2.0.286
g.burck
Beiträge: 228 Registriert: 23 Mai 2018, 16:44
Beitrag
von g.burck » 02 Apr 2020, 11:54
Danke schon mal.
Läuft das automatisch elevated?
opsi config editor Version 4.1.9.8.5 (2021/04/12)
opsiconfd 4.2.0.286
g.burck
Beiträge: 228 Registriert: 23 Mai 2018, 16:44
Beitrag
von g.burck » 02 Apr 2020, 14:03
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
opsi config editor Version 4.1.9.8.5 (2021/04/12)
opsiconfd 4.2.0.286
g.burck
Beiträge: 228 Registriert: 23 Mai 2018, 16:44
Beitrag
von g.burck » 02 Apr 2020, 15:47
opsi config editor Version 4.1.9.8.5 (2021/04/12)
opsiconfd 4.2.0.286
SisterOfMercy
Beiträge: 1556 Registriert: 22 Jun 2012, 19:18
Beitrag
von SisterOfMercy » 08 Apr 2020, 12:11
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.
Bitte schreiben Sie Deutsch, when I'm responding in the German-speaking part of the forum!
feltel
Beiträge: 280 Registriert: 09 Dez 2014, 07:22
Beitrag
von feltel » 10 Apr 2020, 11:48
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