[x] Cleaned up the "InstallWinget" function to be more resilient
[x] Task scheduler is only invoked when the "RunAsUser" parameter is set to true
[x] Cleaned up the code flow to split "RunAsUser" branch from provisioning context branch
[x] Added more traces via Write-Host and Write-Error
[x] Correctly return non-zero exit codes when winget tasks fail
[x] Added new InlineConfigurationBase64 parameter, and new code branch for it in both "RunAsUser" and provisioning context scenarios.
[x] Tested all changes locally
How testing was done
Most changes were trivial to test. For "RunAsUser" as well as the classically supported provisioning context, I ran a terminal as system via psexec -s pwsh, confirming I'm running as system by seeing that whoami returns nt authority\system. I then ran all the scenarios in the examples of task.yaml by manually invoking main.ps1 with the adequate parameters.
For the new functionality, I tested running it under the user context, not system, and did so by having a winget configuration file and running the following commands:
Changes done
Write-Host
andWrite-Error
InlineConfigurationBase64
parameter, and new code branch for it in both "RunAsUser" and provisioning context scenarios.How testing was done
Most changes were trivial to test. For "RunAsUser" as well as the classically supported provisioning context, I ran a terminal as system via
psexec -s pwsh
, confirming I'm running as system by seeing thatwhoami
returnsnt authority\system
. I then ran all the scenarios in the examples of task.yaml by manually invokingmain.ps1
with the adequate parameters.For the new functionality, I tested running it under the user context, not system, and did so by having a winget configuration file and running the following commands:
The machine was configured as expected. For my configuration file, I used these contents: