Migrate-TisaneModulesToPs7.ps1
<#PSScriptInfo .VERSION 1.4 .GUID 1e051b95-e17c-4be6-9255-1067a96094b1 .AUTHOR Chirag Rade .COMPANYNAME Tisane Labs .COPYRIGHT (c) Tisane Labs All rights reserved .TAGS .LICENSEURI .PROJECTURI .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS .EXTERNALSCRIPTDEPENDENCIES .RELEASENOTES #> <# .DESCRIPTION Update powershell to powershell 7 and migrate tisane modules for the same #> Param() $modulesToMigrate = @( "LampSettingLib", "TisaneLampClient", "TisaneLampServer", "TisaneLocal", "TisaneOnprem", "TisaneWeb" ) $modulesToInstall = @() foreach ($moduleName in $modulesToMigrate) { try { Write-Verbose "Uninstalling $moduleName from PowerShell 5..." Uninstall-Module -Name $moduleName -Force -Verbose -ErrorAction Stop Write-Host "$moduleName uninstalled" $modulesToInstall += $moduleName } catch { continue } } Write-Host "Installing PowerShell 7" -ForegroundColor Green Start-Process -Wait -FilePath msiexec.exe -ArgumentList /i, "https://github.com/PowerShell/PowerShell/releases/download/v7.3.6/PowerShell-7.3.6-win-x64.msi", /passive, ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1, ADD_FILE_CONTEXT_MENU_RUNPOWERSHELL=1, ENABLE_PSREMOTING=1, REGISTER_MANIFEST=1, USE_MU=0, ENABLE_MU=0, ADD_PATH=1 Write-Host "successfully installed PowerShell 7" -ForegroundColor Green #refresh path $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") Write-Host "Installing new versions of module" foreach ($moduleName in $modulesToInstall) { Write-Verbose "Installing $moduleName in PowerShell 7..." pwsh.exe -Command { param($moduleName) Install-Module -Name $moduleName -Force -Confirm:$false } -args $moduleName Write-Host "$moduleName installed in PowerShell 7." } |