TerminalSystemUpdate.ps1

$logsPath = Join-Path $env:ProgramData 'Logeto\Terminal\Logs'
Start-Transcript -OutputDirectory $logsPath -IncludeInvocationHeader
$importModuleScriptPath = Join-Path $env:ProgramData 'Logeto\Terminal\SystemUpdate\InstallLogetoModule.ps1'
. $importModuleScriptPath
Import-Module -Name "Logeto"
try
{
    Update-LogetoProductSystemEnvironment 'Terminal' 'All'
}
finally
{
    $packageName = "B158BDD8.LogetoTerminal_kaaqb1ec1n05t"
    $usersInfo = Get-AppxPackage -AllUsers | ? {$_.PackageFamilyName -eq $packageName}

    ForEach ($user in $usersInfo)
    {
        $sid = $user.PackageUserInformation.UserSecurityId.SID
        $user = Get-childItem -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList' | ForEach-Object {Get-ItemProperty -Path $_.pspath } | Where-Object { $_.pschildname -eq $sid}
        $path = $user.profileImagePath
        $localPath = "$path\AppData\Local\Packages\$packageName\LocalState"
    
        if (Test-Path $localPath)
        {
            $local = Get-InstalledModule -AllVersions -Name "Logeto"
            $a = [system.String]::Join(", ", $local.Version)
            $a | Out-File "$localPath\PSVersionSystem.txt"

            $serviceExePath = "$ENV:ProgramFiles\Systemart\Logeto.UWP.Service\Logeto.UWP.Service.Host.exe"
            if (Test-Path $serviceExePath)
            {
                $v = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($serviceExePath).FileVersion
                $v | Out-File "$localPath\ServiceVersion.txt"
            }
        } 
    }
}