0

Trialing out employee monitoring software. It easily installs and works using Software Installation but the users we have are already remote connecting via the VPN. Since software install needs it to work on logon, scheduled tasks while the VPN is connected appears to be the best solution. It is Workpuls and below is the step by step instructions and code. I have ran the Powershell directly on my machine and it works. I should point out that if any entry in the registry for Workpuls is seen, it will not work. I am able to get the GPO to push out and for the Task Scheduler to add the task, but it does not install the MSI. It does add the registry entry, so the script is called on, but I feel like it is an execution policy or permission problem. I contacted their support but they were not able to help. The scheduled tasks run last message shows 0x1. What am I missing?

https://drive.google.com/file/d/1EZTIb1iwPQwlOx7XQDkCziaWucuz_mfO/view

I also tried the solution here and that did not fix the problem: Solution

# Remote location from where to pull the installation file
$remote = "\\ourUNCpath\Workpuls.msi"

$rand = Get-Random
# Location where MSI will be downloaded
$local = $env:TEMP + "\" + $rand + ".msi"

# Iteration, increment if updating or so
$value = 1
# Name of they key in the registry containing iteration
$name = "Iteration"
# Location in the registry where key will be placed
$path = "HKLM:\Software\Workpuls" 


# Check if key for iteration exists, otherwise set it to 0
if(!(Test-Path $path))
{
     New-Item -Path $path -Force | Out-Null
     New-ItemProperty -Path $path -Name $name -Value 0
}

# If number is not matching current iteration, run it again.
if((Get-ItemProperty -Path HKLM:\Software\Workpuls).Iteration -ne $value){

    Write-Host "Downloading to" + $local
    Copy-Item $remote -Destination $local -Verbose

    if (-not (Test-Path -Path $local -PathType Leaf)) {
        throw "File doesn't exisits"
    }

    Write-Host "Installing"
    Try
    {
        Start-Process C:\Windows\System32\msiexec.exe -ArgumentList "/i $local /quiet" -Wait -NoNewWindow
    }
    Catch
    {
        Write-Host "Installing v2"
        Try
        {
            Start-Process msiexec.exe -ArgumentList "/i $local /quiet" -Wait -NoNewWindow
        }
        Catch
        {
        }
    }

    Write-Host "Marking job as done"
    New-ItemProperty -Path $path -Name $name -Value $value -Force | Out-Null
}
BMoreIT
  • 11
  • 1

0 Answers0