Public/ps1/Configuration/Upgrade/Start-ApprxrUpgrade.ps1
|
<#
.SYNOPSIS Upgrades the Apprxr module to the latest version. .DESCRIPTION Removes, uninstalls, and reinstalls the Apprxr module, then reloads it into the current session. .EXAMPLE Start-ApprxrUpgrade .NOTES Used to ensure the latest version of Apprxr is installed and loaded. #> function Start-ApprxrUpgrade { (Get-module Apprxr).Version Remove-Module Apprxr Uninstall-Module Apprxr Install-Module Apprxr Import-Module Apprxr start-process PowerShell (Get-module Apprxr).Version start-sleep -Seconds 5 # Start Restart-ApprxrService in a separate process to avoid stopping the current service Write-Host "Starting service restart in a separate process..." -ForegroundColor Yellow $restartScript = @" Import-Module Apprxr Start-Sleep -Seconds 2 Restart-ApprxrService "@ Start-Process -FilePath "powershell.exe" -ArgumentList "-NoProfile -Command `"$restartScript`"" -WindowStyle Hidden Write-Host "Service restart initiated in background process." -ForegroundColor Green } |