<# .SYNOPSIS Instala Microsoft Store en Windows 10 LTSC 2021 via irm | iex. Port PowerShell de ishad0w/microsoft-windows-10-ltsc-2021-microsoft-store. .DESCRIPTION Replica Install_Microsoft_Libs_and_Store.bat: 1. Libs NET.Native + VCLibs + UI.Xaml (segun arch x64/x86) 2. Microsoft Store (neutral .msixbundle) Usa Add-AppxProvisionedPackage -Online -SkipLicense como el .bat, mas Add-AppxPackage para dejarlo disponible en la sesion actual. Fuente paquetes (99 MB aprox): https://github.com/ishad0w/microsoft-windows-10-ltsc-2021-microsoft-store/releases/download/2022-04-01/Install_Microsoft_Libs_and_Store.zip Contiene: Framework 2.2, Runtime 2.2, UI.Xaml 2.7, VCLibs 14.0.30704, Store 22112. Requiere: Windows 10 LTSC (ideal 21H2 build 19044) + PowerShell como Administrador. .EXAMPLE # Como Administrador: # irm https://raw.githubusercontent.com/TU-USUARIO/TU-REPO/main/Install-Store.ps1 | iex .EXAMPLE # Solo libs, sin Store (equivale a cerrar el .bat en el segundo pause): # $env:LTSC_STORE_NO_STORE = "1"; irm | iex .EXAMPLE # Local: # powershell -NoProfile -ExecutionPolicy Bypass -File .\Install-Store.ps1 .NOTES Env vars (para irm | iex, donde no se pasan params): LTSC_STORE_ZIP_URL - URL del ZIP (por defecto: release 2022-04-01 de ishad0w) LTSC_STORE_KEEP - "1" = no borrar TEMP LTSC_STORE_SKIP_VERSION_CHECK - "1" = saltar chequeo de build LTSC_STORE_NO_STORE - "1" = solo libs, no instala Store #> [CmdletBinding()] param( [string]$ZipUrl = "", [string]$WorkDir = "", [switch]$KeepFiles, [switch]$SkipVersionCheck, [switch]$NoStore ) $ErrorActionPreference = "Stop" $ProgressPreference = "SilentlyContinue" try { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 } catch {} # --- Defaults + env (clave para irm | iex) --- $DefaultZip = "https://github.com/ishad0w/microsoft-windows-10-ltsc-2021-microsoft-store/releases/download/2022-04-01/Install_Microsoft_Libs_and_Store.zip" if ([string]::IsNullOrWhiteSpace($ZipUrl)) { if (-not [string]::IsNullOrWhiteSpace($env:LTSC_STORE_ZIP_URL)) { $ZipUrl = $env:LTSC_STORE_ZIP_URL } else { $ZipUrl = $DefaultZip } } if (-not $KeepFiles -and $env:LTSC_STORE_KEEP -eq "1") { $KeepFiles = $true } if (-not $SkipVersionCheck -and $env:LTSC_STORE_SKIP_VERSION_CHECK -eq "1") { $SkipVersionCheck = $true } if (-not $NoStore -and $env:LTSC_STORE_NO_STORE -eq "1") { $NoStore = $true } if ([string]::IsNullOrWhiteSpace($WorkDir)) { $base = $env:TEMP if ([string]::IsNullOrWhiteSpace($base)) { $base = $PWD.Path } $WorkDir = Join-Path $base ("LTSC2021-Store-" + [Guid]::NewGuid().ToString("N").Substring(0, 8)) } function Test-IsAdmin { $id = [Security.Principal.WindowsIdentity]::GetCurrent() $p = New-Object Security.Principal.WindowsPrincipal($id) return $p.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) } function Get-StoreArch { # Replica bat: if "%PROCESSOR_ARCHITECTURE%"=="x86" (x86) else (x64) if ($env:PROCESSOR_ARCHITECTURE -ieq "x86") { return "x86" } return "x64" } function Find-Packages($Root, $NamePart, $ArchPart, $Ext) { return @(Get-ChildItem -Path $Root -Recurse -File -ErrorAction SilentlyContinue | Where-Object { ($_.Name -like ("*" + $NamePart + "*")) -and ($_.Name -like ("*" + $ArchPart + "*")) -and ($_.Name -like ("*." + $Ext)) } | Sort-Object FullName) } function Install-Provisioned($File) { $leaf = Split-Path $File.FullName -Leaf Write-Host ("--> " + $leaf) try { Add-AppxProvisionedPackage -Online -PackagePath $File.FullName -SkipLicense -ErrorAction Stop | Out-Null Write-Host " [OK] Provisioned" } catch { Write-Warning (" Provisioned fallo (sigo con Add-AppxPackage): " + $_.Exception.Message) } try { Add-AppxPackage -Path $File.FullName -ErrorAction Stop Write-Host " [OK] Add-AppxPackage" } catch { Write-Warning (" Add-AppxPackage fallo: " + $_.Exception.Message) throw } } # --- 1. Admin (el bat usa net session; aqui rol Administrator) --- if (-not (Test-IsAdmin)) { throw "ERROR: Ejecuta PowerShell como Administrador (click derecho > Ejecutar como administrador) y repite el comando." } # --- 2. Version (LTSC 2021 = 19044; minimo 17763 para Framework 2.2 / Xaml 2.7) --- if (-not $SkipVersionCheck) { $build = 0 try { $build = [int](Get-CimInstance Win32_OperatingSystem -ErrorAction Stop).BuildNumber } catch { try { $build = [Environment]::OSVersion.Version.Build } catch {} } Write-Host ("Windows build: $build") if ($build -ne 0 -and $build -lt 17763) { throw "ERROR: Se recomienda Windows 10 1809+ / LTSC 2021 (19044). Detectado: $build. Usa -SkipVersionCheck o LTSC_STORE_SKIP_VERSION_CHECK=1 para forzarlo." } } # --- 3. Arch --- $arch = Get-StoreArch Write-Host ("Arquitectura: $arch ($env:PROCESSOR_ARCHITECTURE)") # --- 4. Descargar + expandir --- $zipFile = Join-Path $WorkDir "store.zip" $extractDir = Join-Path $WorkDir "src" New-Item -ItemType Directory -Path $extractDir -Force | Out-Null Write-Host ("Descargando (~99MB): $ZipUrl") Invoke-WebRequest -Uri $ZipUrl -OutFile $zipFile -UseBasicParsing Write-Host ("Expandiendo a: $extractDir") Expand-Archive -Path $zipFile -DestinationPath $extractDir -Force # --- 5. Buscar paquetes (equivale a dir /b /s "*name*arch*.ext") --- $libs = @() $libs += Find-Packages $extractDir "NET.Native" $arch "appx" $libs += Find-Packages $extractDir "VCLibs" $arch "appx" $libs += Find-Packages $extractDir "Xaml" $arch "appx" if ($libs.Count -eq 0) { throw "ERROR: No se encontraron libs (*NET.Native/*VCLibs/*Xaml *$arch*.appx) en el ZIP." } $storePkgs = Find-Packages $extractDir "WindowsStore" "neutral" "msixbundle" if ($storePkgs.Count -eq 0) { # fallback por si el pack es viejo (.appxbundle como kkkgo) $storePkgs = Find-Packages $extractDir "WindowsStore" "neutral" "appxbundle" } Write-Host "" Write-Host "============================================================" Write-Host "Install Microsoft .Net and VC Libs" Write-Host "============================================================" foreach ($f in $libs) { Install-Provisioned $f } if (-not $NoStore) { if ($storePkgs.Count -eq 0) { throw "ERROR: No se encontro *WindowsStore*neutral*.msixbundle en el ZIP." } Write-Host "" Write-Host "============================================================" Write-Host "Install Microsoft Store" Write-Host "============================================================" foreach ($f in $storePkgs) { Install-Provisioned $f } } else { Write-Host "(Store omitido por LTSC_STORE_NO_STORE=1 / -NoStore)" } Write-Host "" Write-Host "============================================================" Write-Host "Done!" Write-Host "============================================================" Write-Host "Si la Store no abre: reinicia. Luego WSReset.exe si hace falta."