String variables
parent
59df5ada2b
commit
7392ec0536
|
@ -170,10 +170,10 @@ function Install-Prerequisites {
|
|||
Write-host "-> Installing VC_redist.$OSArch.exe..."
|
||||
Start-Process -FilePath $Installer -Args "/quiet /norestart" -Wait
|
||||
Remove-Item $Installer -ErrorAction Ignore
|
||||
Write-host "MS Visual C++ 2015-2022 installed successfully" -ForegroundColor Green
|
||||
Write-host "-> MS Visual C++ 2015-2022 installed successfully" -ForegroundColor Green
|
||||
}
|
||||
catch {
|
||||
Write-host "MS Visual C++ 2015-2022 installation failed." -ForegroundColor Red
|
||||
Write-host "-> MS Visual C++ 2015-2022 installation failed." -ForegroundColor Red
|
||||
Start-Sleep 3
|
||||
}
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ function Install-Prerequisites {
|
|||
}
|
||||
}
|
||||
else {
|
||||
Write-Host "Prerequisites checked. OK" -ForegroundColor Green
|
||||
Write-Host "-> Prerequisites checked. OK" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,10 +228,10 @@ function Install-WinGet {
|
|||
try {
|
||||
Write-Host "-> Installing Microsoft.UI.Xaml.2.7..."
|
||||
Add-AppxProvisionedPackage -Online -PackagePath "$WingetUpdatePath\extracted\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.7.appx" -SkipLicense | Out-Null
|
||||
Write-host "Microsoft.UI.Xaml.2.7 installed successfully" -ForegroundColor Green
|
||||
Write-host "-> Microsoft.UI.Xaml.2.7 installed successfully" -ForegroundColor Green
|
||||
}
|
||||
catch {
|
||||
Write-Host "Failed to intall Wicrosoft.UI.Xaml.2.7..." -ForegroundColor Red
|
||||
Write-Host "-> Failed to intall Wicrosoft.UI.Xaml.2.7..." -ForegroundColor Red
|
||||
}
|
||||
Remove-Item -Path $UiXamlZip -Force
|
||||
Remove-Item -Path "$WingetUpdatePath\extracted" -Force -Recurse
|
||||
|
@ -245,10 +245,10 @@ function Install-WinGet {
|
|||
try {
|
||||
Write-Host "-> Installing Microsoft.VCLibs.140.00.UWPDesktop..."
|
||||
Add-AppxProvisionedPackage -Online -PackagePath $VCLibsFile -SkipLicense | Out-Null
|
||||
Write-host "Microsoft.VCLibs.140.00.UWPDesktop installed successfully" -ForegroundColor Green
|
||||
Write-host "-> Microsoft.VCLibs.140.00.UWPDesktop installed successfully" -ForegroundColor Green
|
||||
}
|
||||
catch {
|
||||
Write-Host "Failed to intall Microsoft.VCLibs.140.00.UWPDesktop..." -ForegroundColor Red
|
||||
Write-Host "-> Failed to intall Microsoft.VCLibs.140.00.UWPDesktop..." -ForegroundColor Red
|
||||
}
|
||||
Remove-Item -Path $VCLibsFile -Force
|
||||
}
|
||||
|
|
|
@ -2,11 +2,14 @@
|
|||
|
||||
Function Update-StoreApps ($Log = $false) {
|
||||
|
||||
$force_string = "-> Forcing an upgrade of Store Apps (this can take a minute)..."
|
||||
$fail_string = "-> ...something went wrong!"
|
||||
|
||||
#If not WSB or Server, upgrade Microsoft Store Apps!
|
||||
if (!(Test-Path "${env:SystemDrive}\Users\WDAGUtilityAccount") -and (Get-CimInstance Win32_OperatingSystem).Caption -notmatch "Windows Server") {
|
||||
switch ($Log) {
|
||||
$true {Write-ToLog "-> Forcing an upgrade of Store Apps (this can take a minute)..." "yellow"}
|
||||
Default {Write-Host "-> Forcing an upgrade of Store Apps (this can take a minute)..." -ForegroundColor Yellow}
|
||||
$true {Write-ToLog $force_string "yellow"}
|
||||
Default {Write-Host $force_string -ForegroundColor Yellow}
|
||||
}
|
||||
try {
|
||||
$namespaceName = "root\cimv2\mdm\dmmap"
|
||||
|
@ -17,8 +20,8 @@ Function Update-StoreApps ($Log = $false) {
|
|||
}
|
||||
catch {
|
||||
switch ($Log) {
|
||||
$true {Write-ToLog "-> ...something went wrong!" "red"}
|
||||
Default {Write-Host "-> ...something went wrong!" -ForegroundColor Red}
|
||||
$true {Write-ToLog $fail_string "red"}
|
||||
Default {Write-Host $fail_string -ForegroundColor Red}
|
||||
}
|
||||
return $false
|
||||
}
|
||||
|
|
|
@ -2,10 +2,16 @@
|
|||
|
||||
Function Update-WinGet ($WinGetAvailableVersion, $DownloadPath, $Log = $false) {
|
||||
|
||||
$download_string = "-> Downloading WinGet MSIXBundle for App Installer..."
|
||||
$install_string = "-> Installing WinGet MSIXBundle for App Installer..."
|
||||
$success_string = "-> WinGet MSIXBundle (v$WinGetAvailableVersion) for App Installer installed successfully"
|
||||
$reset_string = "-> WinGet sources reset."
|
||||
$fail_string = "-> Failed to intall WinGet MSIXBundle for App Installer..."
|
||||
|
||||
#Download WinGet MSIXBundle
|
||||
switch ($Log) {
|
||||
$true {Write-ToLog "-> Downloading WinGet MSIXBundle for App Installer..."}
|
||||
Default {Write-Host "-> Downloading WinGet MSIXBundle for App Installer..."}
|
||||
$true {Write-ToLog $download_string}
|
||||
Default {Write-Host $download_string}
|
||||
}
|
||||
$WinGetURL = "https://github.com/microsoft/winget-cli/releases/download/v$WinGetAvailableVersion/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
|
||||
$WebClient = New-Object System.Net.WebClient
|
||||
|
@ -14,21 +20,21 @@ Function Update-WinGet ($WinGetAvailableVersion, $DownloadPath, $Log = $false) {
|
|||
#Install WinGet MSIXBundle in SYSTEM context
|
||||
try {
|
||||
switch ($Log) {
|
||||
$true {Write-ToLog "-> Installing WinGet MSIXBundle for App Installer..."}
|
||||
Default {Write-Host "-> Installing WinGet MSIXBundle for App Installer..."}
|
||||
$true {Write-ToLog $install_string}
|
||||
Default {Write-Host $install_string}
|
||||
}
|
||||
Add-AppxProvisionedPackage -Online -PackagePath "$DownloadPath\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -SkipLicense | Out-Null
|
||||
switch ($Log) {
|
||||
$true {Write-ToLog "-> WinGet MSIXBundle (v$WinGetAvailableVersion) for App Installer installed successfully" "green"}
|
||||
Default {Write-host "WinGet MSIXBundle (v$WinGetAvailableVersion) for App Installer installed successfully" -ForegroundColor Green}
|
||||
$true {Write-ToLog $success_string "green"}
|
||||
Default {Write-host $success_string -ForegroundColor Green}
|
||||
}
|
||||
|
||||
#Reset WinGet Sources
|
||||
$ResolveWingetPath = Resolve-Path "$env:programfiles\WindowsApps\Microsoft.DesktopAppInstaller_*_*__8wekyb3d8bbwe\winget.exe" | Sort-Object { [version]($_.Path -replace '^[^\d]+_((\d+\.)*\d+)_.*', '$1') }
|
||||
if ($ResolveWingetPath) {
|
||||
switch ($Log) {
|
||||
$true {Write-ToLog "-> WinGet sources reset." "green"}
|
||||
Default {Write-Host "-> WinGet sources reset." -ForegroundColor Green}
|
||||
$true {Write-ToLog $reset_string "green"}
|
||||
Default {Write-Host $reset_string -ForegroundColor Green}
|
||||
}
|
||||
#If multiple version, pick last one
|
||||
$WingetPath = $ResolveWingetPath[-1].Path
|
||||
|
@ -37,8 +43,8 @@ Function Update-WinGet ($WinGetAvailableVersion, $DownloadPath, $Log = $false) {
|
|||
}
|
||||
catch {
|
||||
switch ($Log) {
|
||||
$true {Write-ToLog "-> Failed to intall WinGet MSIXBundle for App Installer..." "red"}
|
||||
Default {Write-Host "Failed to intall WinGet MSIXBundle for App Installer..." -ForegroundColor Red}
|
||||
$true {Write-ToLog $fail_string "red"}
|
||||
Default {Write-Host $fail_string -ForegroundColor Red}
|
||||
}
|
||||
Update-StoreApps
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue