I added a do while statement to the script so the script will keep trying to install until the program is installed. Below is the complete script. Can anyone confirm if this is the correct way to this.
<#
.SYNOPSIS
Downloads and installs Citrix WorkspaceApp.
Intended to run via Intune.
#>
do{
# If WorkspaceApp is already installed, skip download and install
If ((!(Get-WmiObject -Class Win32_Product | Where-Object Name -Like "Citrix Workspace*"))) {
# Citrix Workspace App download source
$Url = "https://downloadplugins.citrix.com/Windows/CitrixWorkspaceApp.exe"
$Target = "$env:SystemRoot\Temp\CitrixWorkspaceApp.exe"
# Delete the target if it exists, so that we don't have issues
If (Test-Path $Target) { Remove-Item -Path $Target -Force -ErrorAction SilentlyContinue }
# Download Citrix Receiver locally
Start-BitsTransfer -Source $Url -Destination $Target
# Install Citrix Receiver
If (Test-Path $Target) { Start-Process -FilePath $Target -ArgumentList "/AutoUpdateCheck=auto /AutoUpdateStream=Current /AllowAddStore=N /DeferUpdateCount=5 /AURolloutPriority=Medium /NoReboot /Silent EnableCEIP=False" -Wait }
}
} while ((!(Get-WmiObject -Class Win32_Product | Where-Object Name -Like "Citrix Workspace*")))