Compiled SelfUpdating Script only loading right modules on the 2nd run

Hi guys, let me see if I can explain this correctly.

I wrote a Self updating script, it connects to a server and checks accordingly to it’s productversion if it has an update and downloads it.
(the script is compiled to an EXE using powershell pro tools)
(the script also has several modules, that get compiled along with the exe)

When I start the new version, all the changes that I’ve made to the main script .ps1 file get automatically loaded, but if I make changes in a module, they do not run from the self invoked new version the first time it runs. only on the second time I call it.

I’ve tried to directly invoke the new version

Start-Process powershell -ArgumentList { while ($null -ne (get-process SystemHealth -ErrorAction SilentlyContinue)) { get-process SystemHealth | Stop-Process -Force; Start-Sleep -Milliseconds 200 }; Start-Process “C:\xxxxxxxxx\Tools\Scripts\SystemHealth\SystemHealth.exe” -ArgumentList “-noupdate” -WindowStyle Minimized; Exit } -WindowStyle Minimized

and I’ve tried creating a batch file that calls the new version

#Create Batch File
$PSDefaultParameterValues[‘Out-File:Encoding’] = ‘default’ #Set encoding to default so the resulting files don’t have a strange format
Set-Location $global:systemHealthFolder
$myInvocationBatchFilePath = “$global:systemHealthFolder\CallSysHealth.bat”
New-item -path $myInvocationBatchFilePath -ItemType File
@echo off’ | Out-File $myInvocationBatchFilePath -Append -Force
‘timeout /t 1’ | Out-File $myInvocationBatchFilePath -Append -Force
‘taskkill /im systemhealth.exe /f’ | Out-File $myInvocationBatchFilePath -Append -Force
‘timeout /t 1’ | Out-File $myInvocationBatchFilePath -Append -Force
‘del /f SystemHealth.exe.old’ | Out-File $myInvocationBatchFilePath -Append -Force
‘timeout /t 1’ | Out-File $myInvocationBatchFilePath -Append -Force
‘start C:\Hologate\Tools\Scripts\SystemHealth\SystemHealth.exe -noupdate’ | Out-File $myInvocationBatchFilePath -Append -Force
Write-log “Calling batch file…”
Stop-Transcript
Start-Process -FilePath $myInvocationBatchFilePath -Wait
Exit

but with both methods I will have the same problem… any hints would be much appreciated