1.0.0/RepairWindows.psm1
function Check-Admin { # Check if the script is run as administrator if (-not ([bool](New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))) { Write-Error "This script must be run as an administrator." exit 1 } } function Run-Command { param ( [string]$Command, [string]$Description ) Write-Output "Running: $Description" try { Invoke-Expression $Command Write-Output "Success: $Description" } catch { Write-Error "Failed: $Description" } } function ReRegister-Apps { # Re-register Microsoft Store apps Write-Output "Running: Re-register Microsoft Store apps" try { $appPaths = Get-AppxPackage -AllUsers | ForEach-Object { Join-Path -Path $_.InstallLocation -ChildPath "AppxManifest.xml" } foreach ($path in $appPaths) { if (Test-Path $path) { Add-AppxPackage -DisableDevelopmentMode -Register $path Write-Output "Success: Re-registered app with manifest at $path" } else { Write-Error "AppXManifest.xml not found at $path" } } } catch { Write-Error "Failed: Re-register Microsoft Store apps" } } |