Powershell Add-AppPackage und OPSI (Winget)

Antworten
gx2119
Beiträge: 3
Registriert: 22 Feb 2022, 16:15

Powershell Add-AppPackage und OPSI (Winget)

Beitrag von gx2119 »

Hey,
ich versuche grade winget automatisch auf clients zu instalieren.
Hierbei will ich die .msixbundle auf c:\tmp\ zu kopieren und dann das powershellskript ausführen in dem der comand für die instalation steht. (mit powershellCall($befehl$) habe ich es auch schon probiert.
beides leider ohne erfolg.
Andere befehle wie z.b. mkdir gehen aber ohne probleme.
wenn ich die ps1 aber so in der powershell laufen lasse geht es ohne probleme.

Code: Alles auswählen

[Actions]
include_insert "common.opsiinc"
ShowBitmap "%ScriptPath%\winget.png" $ProductId$
Message "Create install folder on c:"
comment "Installing Winget"
Set $bevor$ = powershellCall('winget')
powershellCall('mkdir ' + $Path$)
Message "coppy install datei to PC"


LogWarning $copy$

Files_copy
DosInAnIcon_PSRetVal_Enable
Message "Trying to install packeg"
;swpowershellCall($Powersellcommand$)
Set $after$ = powershellCall('winget')

;if ($after$ == $bevor$)
;    LogError "Winget war entweder schon instaliert oder es gab probleme beim instalieren von Wingets"
;    isFatalError
;endif
Message "aufäumen..."
;powershellCall('rm -r -fo ' + $Path$)
;==============================================================================================================================

[Files_copy]
copy $copy$

[DosInAnIcon_PSRetVal_Enable]
powershell.exe -file %ScriptPath%\do_the_magic.ps1
exit %ERRORLEVEL%
;Get-AppXPackage Microsoft.DesktopAppInstaller | Remove-AppPackage  == uninstall den shit again.s
do_the_magic.ps1

Code: Alles auswählen

Add-AppPackage -path C:\tmp\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle

Code: Alles auswählen

;CTRL_Vars------------------------
DefVar $ProductId$
;Others---------------------------
DefVar $msixbundle$
DefVar $Path$
DefVar $Path_msixbundle$
DefVar $Powersellcommand$
DefVar $bevor$
DefVar $after$
DefVar $copy$
DefVar $ScriptPath$
;Set------------------------------
Set $ScriptPath$ = "%ScriptPath%\"
Set $ProductId$ = "winget_install-winget"
Set $msixbundle$ = "Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
Set $Path$ = "C:\temp\"
Set $Powersellcommand$ = "Add-AppPackage -path "+ $Path$+$msixbundle$
Set $copy$ = $ScriptPath$ + $msixbundle$ + " "+ $Path$


Benutzeravatar
ThomasT
uib-Team
Beiträge: 565
Registriert: 26 Jun 2013, 12:26

Re: Powershell Add-AppPackage und OPSI (Winget)

Beitrag von ThomasT »

Ich vermute mal dass das AppPackage im Userkontext installiert werden möchte.
OPSI ruft die Powershell als System-User auf und der hat nur in beschränktem Maß Ähnlichkeit mit einem normalen User...


Vielen Dank für die Nutzung von opsi. Im Forum ist unser Support begrenzt.

Für den professionellen Einsatz und individuelle Beratung empfehlen wir einen Support-Vertrag und eine Schulung.
Gerne informieren wir Sie zu unserem Angebot.

uib GmbH
Telefon: +49 6131 27561 0
E-Mail: sales@uib.de


Michael H.
Beiträge: 15
Registriert: 10 Feb 2016, 11:28

Re: Powershell Add-AppPackage und OPSI (Winget)

Beitrag von Michael H. »

Hallo versuch es mal damit im [WinBatch_Setup] bereich:
powershell -windowstyle hidden -command "Add-AppProvisionedPackage -online -packagepath C:\tmp\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle' -skiplicense"

Gruß
Michael
Benutzeravatar
SisterOfMercy
Beiträge: 1556
Registriert: 22 Jun 2012, 19:18

Re: Powershell Add-AppPackage und OPSI (Winget)

Beitrag von SisterOfMercy »

Remove-AppxPackage has the -AllUsers parameter, maybe this one does too?
Bitte schreiben Sie Deutsch, when I'm responding in the German-speaking part of the forum!
gx2119
Beiträge: 3
Registriert: 22 Feb 2022, 16:15

Re: Powershell Add-AppPackage und OPSI (Winget)

Beitrag von gx2119 »

Michael H. hat geschrieben: 03 Mär 2022, 14:19 Hallo versuch es mal damit im [WinBatch_Setup] bereich:
powershell -windowstyle hidden -command "Add-AppProvisionedPackage -online -packagepath C:\tmp\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle' -skiplicense"

Gruß
Michael
Hey, danke für die idee leider geht es immer noch nicht.

Code: Alles auswählen

(124)     [6] [2022-03-16 15:01:05.870] [winget_install-winget]   The value of the variable "$Path$" is now: "C:\temp\"
(125)     [6] [2022-03-16 15:01:05.870] [winget_install-winget] Set  $Powersellcommand$ = "Add-AppPackage -path "+ $Path$+$msixbundle$
(126)     [6] [2022-03-16 15:01:05.870] [winget_install-winget]   The value of the variable "$Powersellcommand$" is now: "Add-AppPackage -path C:\temp\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
(127)     [6] [2022-03-16 15:01:05.870] [winget_install-winget] Set  $copy$ = $ScriptPath$ + $msixbundle$ + " "+ $Path$
(128)     [6] [2022-03-16 15:01:05.870] [winget_install-winget]   The value of the variable "$copy$" is now: "p:\winget_install-winget\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle C:\temp\"
(129)     [5] [2022-03-16 15:01:05.892] [winget_install-winget] message Create install folder on c:
(130)     [5] [2022-03-16 15:01:05.893] [winget_install-winget] comment: Installing Winget
(131)     [6] [2022-03-16 15:01:05.893] [winget_install-winget] Set  $bevor$ = powershellCall('winget')
(132)     [5] [2022-03-16 15:01:05.894] [winget_install-winget] PowershellCall Executing: winget ; mode: sysnative
(134)     [6] [2022-03-16 15:01:05.894] [winget_install-winget] ShellCall Executing: "C:\Windows\system32\\cmd.exe" /C "powershell.exe get-executionpolicy"
(138)     [6] [2022-03-16 15:01:07.033] [winget_install-winget] ShellCall Executing: "C:\Windows\system32\\cmd.exe" /C "powershell.exe set-executionpolicy RemoteSigned"
(141)     [6] [2022-03-16 15:01:08.158] [winget_install-winget] 
(142)     [6] [2022-03-16 15:01:08.158] [winget_install-winget] Execution of tmp-internal powershell.exe winst /sysnative
(144)     [6] [2022-03-16 15:01:09.902] [winget_install-winget]   ExitCode 1
(160)     [6] [2022-03-16 15:01:09.906] [winget_install-winget] ShellCall Executing: "C:\Windows\system32\\cmd.exe" /C "powershell.exe set-executionpolicy RemoteSigned"
(163)     [6] [2022-03-16 15:01:11.032] [winget_install-winget]   The value of the variable "$bevor$" is now: "1"
(164)     [5] [2022-03-16 15:01:11.034] [winget_install-winget] PowershellCall Executing: mkdir C:\temp\ ; mode: sysnative
(166)     [6] [2022-03-16 15:01:11.034] [winget_install-winget] ShellCall Executing: "C:\Windows\system32\\cmd.exe" /C "powershell.exe get-executionpolicy"
(170)     [6] [2022-03-16 15:01:12.161] [winget_install-winget] ShellCall Executing: "C:\Windows\system32\\cmd.exe" /C "powershell.exe set-executionpolicy RemoteSigned"
(173)     [6] [2022-03-16 15:01:13.186] [winget_install-winget] 
(174)     [6] [2022-03-16 15:01:13.186] [winget_install-winget] Execution of tmp-internal powershell.exe winst /sysnative
(176)     [6] [2022-03-16 15:01:13.914] [winget_install-winget]   ExitCode 0
(190)     [6] [2022-03-16 15:01:13.918] [winget_install-winget] ShellCall Executing: "C:\Windows\system32\\cmd.exe" /C "powershell.exe set-executionpolicy RemoteSigned"
(193)     [5] [2022-03-16 15:01:15.045] [winget_install-winget] message coppy install datei to PC
(194)     [4] [2022-03-16 15:01:15.047] [winget_install-winget] Warning: p:\winget_install-winget\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle C:\temp\
(195)     [5] [2022-03-16 15:01:15.047] [winget_install-winget] Execution of: Files_copy
(196)     [5] [2022-03-16 15:01:15.047] [winget_install-winget] 
(199)     [6] [2022-03-16 15:01:15.052] [winget_install-winget]   Copying  p:\winget_install-winget\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle -----> C:\temp\
(200)     [6] [2022-03-16 15:01:15.052] [winget_install-winget]     1 File(s) found
(207)     [6] [2022-03-16 15:01:15.204] [winget_install-winget]       copy: p:\winget_install-winget\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle copied to C:\temp\
(208)     [6] [2022-03-16 15:01:15.212] [winget_install-winget]     1 File(s) treated
(209)     [5] [2022-03-16 15:01:15.213] [winget_install-winget] Finished section: Files_copy
(210)     [5] [2022-03-16 15:01:15.214] [winget_install-winget] Execution of: WinBatch_Setup
(211)     [5] [2022-03-16 15:01:15.214] [winget_install-winget] 
(212)     [6] [2022-03-16 15:01:15.214] [winget_install-winget]   Call "powershell -windowstyle hidden -command "Add-AppProvisionedPackage -online -packagepath C:\temp\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle' -skiplicense""
(213)     [6] [2022-03-16 15:01:15.214] [winget_install-winget]      Waiting until the called process is finished
(214)     [6] [2022-03-16 15:01:15.215] [winget_install-winget]   Start process as invoker: SYSTEM
(215)     [6] [2022-03-16 15:01:15.219] [winget_install-winget]   Started process "powershell" with Opt: -windowstyle\r\nhidden\r\n-command\r\n"Add-AppProvisionedPackage\r\n-online\r\n-packagepath\r\nC:\temp\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle'\r\n-skiplicense"
(216)     [6] [2022-03-16 15:01:16.170] [winget_install-winget]   ExitCode 1    Executed process "powershell -windowstyle hidden -command "Add-AppProvisionedPackage -online -packagepath C:\temp\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle' -skiplicense""
(224)     [5] [2022-03-16 15:01:16.174] [winget_install-winget] message Trying to install packeg
(225)     [6] [2022-03-16 15:01:16.176] [winget_install-winget] Set  $after$ = powershellCall('winget')
(226)     [5] [2022-03-16 15:01:16.177] [winget_install-winget] PowershellCall Executing: winget ; mode: sysnative
(228)     [6] [2022-03-16 15:01:16.177] [winget_install-winget] ShellCall Executing: "C:\Windows\system32\\cmd.exe" /C "powershell.exe get-executionpolicy"
(232)     [6] [2022-03-16 15:01:17.205] [winget_install-winget] ShellCall Executing: "C:\Windows\system32\\cmd.exe" /C "powershell.exe set-executionpolicy RemoteSigned"
(235)     [6] [2022-03-16 15:01:18.232] [winget_install-winget] 
(236)     [6] [2022-03-16 15:01:18.232] [winget_install-winget] Execution of tmp-internal powershell.exe winst /sysnative
(238)     [6] [2022-03-16 15:01:19.975] [winget_install-winget]   ExitCode 1
(254)     [6] [2022-03-16 15:01:19.980] [winget_install-winget] ShellCall Executing: "C:\Windows\system32\\cmd.exe" /C "powershell.exe set-executionpolicy RemoteSigned"
(257)     [6] [2022-03-16 15:01:21.107] [winget_install-winget]   The value of the variable "$after$" is now: "1"
(258)     [5] [2022-03-16 15:01:21.108] [winget_install-winget] message aufäumen...
gx2119
Beiträge: 3
Registriert: 22 Feb 2022, 16:15

Re: Powershell Add-AppPackage und OPSI (Winget)

Beitrag von gx2119 »

SisterOfMercy hat geschrieben: 03 Mär 2022, 14:52 Remove-AppxPackage has the -AllUsers parameter, maybe this one does too?
Hey,

leider hilft es das auch nicht.
es scheint als bräuchte er tazechlich einen user der die instalation anstosen muss. Leider habe ich noch keinen weg soetwas wie z.b. "runas" ohne die eingabe oder die speicherung des passwortes in klartext.

Gruß
Lars
Antworten