Hello,
I'm trying to create a worklet to deploy LanguageTool on my Windows x64 fleet. However, in the feedback, it says that the installation went well but ultimately fails. Can you help me fix the code?
Evaluation Code
#########################################
# --! Evaluate Compliance !--
if (Get-Win32App | Where-Object { $_.Name -eq $appName }) {
Write-Output "$appName is already installed. Now exiting."
exit 0
}
# Si LanguageTool n'est pas détecté, le worklet déclenchera l'installation
else {
Write-Output "$appName was not detected."
installLanguageTool -AppName $appName -AppInstallerType $appInstallerType -AppURL $appURL -IsSilent
}
Remediation Code
# Set temporary folder path
$tempFolderPath = Join-Path -Path $env:TEMP -ChildPath "automox"
Write-Output "Creating temporary folder at $tempFolderPath"
New-Item -ItemType Directory -Force -Path $tempFolderPath | Out-Null
# Download Language Tool setup executable
$url = "https://languagetool.org/download/windows-app/LanguageTool-latest.exe"
$destinationPath = Join-Path -Path $tempFolderPath -ChildPath "$($url.Split('/')u-1])"
Write-Output "Downloading LanguageTool setup executable from $url to $destinationPath"
Invoke-WebRequest -Uri $url -OutFile $destinationPath
# Install Language Tool using the silent installation switch (/S)
Write-Output "Installing LanguageTool silently"
Start-Process -FilePath $destinationPath -ArgumentList "/S", "-dir", "%APPDATA%\LanguageTool\" -Wait
# Remove the temporary files
Write-Output "Removing temporary files from $tempFolderPath"
Remove-Item -Recurse -Force -Path $tempFolderPath
Thanks in advance,
Doomer