Created
July 24, 2026 08:48
-
-
Save cicalooo/ed8ccd8bba3169c587896d46ca422716 to your computer and use it in GitHub Desktop.
Repair Xbox app loading, sign-in, Gaming Services, and Microsoft Store dependencies on Windows 11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [CmdletBinding()] | |
| param( | |
| [switch]$SkipPackageRegistration | |
| ) | |
| $ErrorActionPreference = 'Continue' | |
| $scriptPath = $MyInvocation.MyCommand.Path | |
| $scriptDirectory = Split-Path -Parent $scriptPath | |
| $logPath = Join-Path $scriptDirectory ("Fix-XboxApp-{0}.log" -f (Get-Date -Format 'yyyyMMdd-HHmmss')) | |
| function Test-Administrator { | |
| $identity = [Security.Principal.WindowsIdentity]::GetCurrent() | |
| $principal = [Security.Principal.WindowsPrincipal]::new($identity) | |
| return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) | |
| } | |
| function Write-Step { | |
| param([string]$Message) | |
| Write-Host | |
| Write-Host "==> $Message" -ForegroundColor Cyan | |
| } | |
| if (-not (Test-Administrator)) { | |
| Write-Host "Administrator permission is required. A Windows approval prompt will appear." | |
| $arguments = @( | |
| '-NoProfile' | |
| '-ExecutionPolicy', 'Bypass' | |
| '-File', "`"$scriptPath`"" | |
| ) | |
| if ($SkipPackageRegistration) { | |
| $arguments += '-SkipPackageRegistration' | |
| } | |
| try { | |
| $process = Start-Process -FilePath 'powershell.exe' -ArgumentList $arguments -Verb RunAs -Wait -PassThru | |
| exit $process.ExitCode | |
| } | |
| catch { | |
| Write-Error "The administrator prompt was cancelled or could not be opened. $($_.Exception.Message)" | |
| exit 1 | |
| } | |
| } | |
| Start-Transcript -Path $logPath -Force | Out-Null | |
| $hadFailure = $false | |
| try { | |
| Write-Host "Xbox app repair for Windows 11" -ForegroundColor Green | |
| Write-Host "This does not uninstall games or reset Windows." | |
| Write-Host "Log: $logPath" | |
| Write-Step "Closing Xbox and Microsoft Store" | |
| @('XboxPcApp', 'GamingServicesUI', 'WinStore.App') | ForEach-Object { | |
| Get-Process -Name $_ -ErrorAction SilentlyContinue | | |
| Stop-Process -Force -ErrorAction SilentlyContinue | |
| } | |
| Start-Sleep -Seconds 1 | |
| Write-Step "Restoring required service startup settings" | |
| $serviceSettings = [ordered]@{ | |
| wlidsvc = 'Manual' | |
| NlaSvc = 'Automatic' | |
| XblAuthManager = 'Manual' | |
| XblGameSave = 'Manual' | |
| XboxNetApiSvc = 'Manual' | |
| GamingServices = 'Automatic' | |
| GamingServicesNet = 'Automatic' | |
| InstallService = 'Manual' | |
| ClipSVC = 'Manual' | |
| LicenseManager = 'Manual' | |
| wuauserv = 'Manual' | |
| } | |
| foreach ($serviceName in $serviceSettings.Keys) { | |
| $service = Get-Service -Name $serviceName -ErrorAction SilentlyContinue | |
| if (-not $service) { | |
| Write-Warning "Service not found: $serviceName" | |
| $hadFailure = $true | |
| continue | |
| } | |
| try { | |
| Set-Service -Name $serviceName -StartupType $serviceSettings[$serviceName] -ErrorAction Stop | |
| Write-Host "Configured $serviceName as $($serviceSettings[$serviceName])." | |
| } | |
| catch { | |
| Write-Warning "Could not configure $serviceName. $($_.Exception.Message)" | |
| $hadFailure = $true | |
| } | |
| } | |
| Write-Step "Starting account, networking, licensing, and Xbox services" | |
| $servicesToStart = @( | |
| 'NlaSvc', | |
| 'wlidsvc', | |
| 'XblAuthManager', | |
| 'XblGameSave', | |
| 'XboxNetApiSvc', | |
| 'GamingServices', | |
| 'GamingServicesNet', | |
| 'InstallService', | |
| 'ClipSVC', | |
| 'LicenseManager' | |
| ) | |
| foreach ($serviceName in $servicesToStart) { | |
| try { | |
| Start-Service -Name $serviceName -ErrorAction Stop | |
| Write-Host "Started $serviceName." | |
| } | |
| catch { | |
| $service = Get-Service -Name $serviceName -ErrorAction SilentlyContinue | |
| if ($service.Status -eq 'Running') { | |
| Write-Host "$serviceName is already running." | |
| } | |
| else { | |
| Write-Warning "Could not start $serviceName. $($_.Exception.Message)" | |
| $hadFailure = $true | |
| } | |
| } | |
| } | |
| if (-not $SkipPackageRegistration) { | |
| Write-Step "Repairing Xbox, Gaming Services, identity, and Store registration" | |
| $packageNames = @( | |
| 'Microsoft.GamingApp', | |
| 'Microsoft.GamingServices', | |
| 'Microsoft.XboxIdentityProvider', | |
| 'Microsoft.WindowsStore' | |
| ) | |
| foreach ($packageName in $packageNames) { | |
| $package = Get-AppxPackage -Name $packageName -ErrorAction SilentlyContinue | |
| if (-not $package) { | |
| Write-Warning "Package not installed for this user: $packageName" | |
| $hadFailure = $true | |
| continue | |
| } | |
| try { | |
| $manifestPath = Join-Path $package.InstallLocation 'AppxManifest.xml' | |
| Add-AppxPackage -DisableDevelopmentMode -Register $manifestPath -ErrorAction Stop | |
| Write-Host "Re-registered $packageName." | |
| } | |
| catch { | |
| Write-Warning "Could not re-register $packageName. $($_.Exception.Message)" | |
| $hadFailure = $true | |
| } | |
| } | |
| } | |
| Write-Step "Final status" | |
| Get-Service -Name $servicesToStart -ErrorAction SilentlyContinue | | |
| Sort-Object Name | | |
| Format-Table Name, Status, StartType -AutoSize | |
| if ($hadFailure) { | |
| Write-Host "Repair completed with one or more warnings. Review the log above." -ForegroundColor Yellow | |
| $exitCode = 2 | |
| } | |
| else { | |
| Write-Host "Repair completed successfully." -ForegroundColor Green | |
| $exitCode = 0 | |
| } | |
| Write-Host "Restart Windows, then open Xbox and try the installation again." | |
| } | |
| finally { | |
| Stop-Transcript | Out-Null | |
| } | |
| Write-Host | |
| Read-Host "Press Enter to close" | |
| exit $exitCode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment