Remote Script Execution on Azure Arc enabled Servers using Custom Script Extension

This article has not been completed yet. However, it may already contain  helpful Information and therefore it has been published at this stage.

$chocolateyAppList = "microsoft-windows-terminal,microsoft-edge,7zip,notepadplusplus"
 
if ([string]::IsNullOrWhiteSpace($chocolateyAppList) -eq $false -or [string]::IsNullOrWhiteSpace($dismAppList) -eq $false)
{ 
    try{
        choco config get cacheLocation 
    }catch{
        Write-Output "Chocolatey not detected, trying to install now"
        iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) 
    } 
}

if ([string]::IsNullOrWhiteSpace($chocolateyAppList) -eq $false){
    Write-Host "Chocolatey Apps Specified" 

    $appsToInstall = $chocolateyAppList -split "," | foreach { "$($_.Trim())" } 
    foreach ($app in $appsToInstall)
    {
        Write-Host "Installing $app"
        & choco install $app /y 1 Write-Output
    } 
}

Note: Microsoft-Windows-Terminal is not supported on Windows Server 2019 Version  1809

powershell -ExecutionPolicy Unrestricted -File choco.ps1

Sources:

Chocolatey with Custom Script Extension on Azure VMs | Blog y actualizaciones de Azure | Microsoft Azure
This blog gives an overview of how to run Chocolatey commands on a remote Azure VM using Custom Script Extension.
Troubleshoot Azure Arc-enabled servers VM extension issues - Azure Arc
This article tells how to troubleshoot and resolve issues with Azure VM extensions that arise with Azure Arc-enabled servers.