Skip to content

Instantly share code, notes, and snippets.

@p0w3rsh3ll
Last active October 20, 2019 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save p0w3rsh3ll/66916a4d68f947f86a8c360831044821 to your computer and use it in GitHub Desktop.
Save p0w3rsh3ll/66916a4d68f947f86a8c360831044821 to your computer and use it in GitHub Desktop.
$k = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\Applications'
Get-ChildItem -Path $k -Recurse |
Where-Object { $_.PSIsContainer} |
ForEach-Object {
$p = $null
if ($p=Get-ItemProperty -Path "$($_.PsPath)" -Name 'Path' -ErrorAction SilentlyContinue) {
$App = Split-Path $_.Name -Leaf
Write-Verbose -Message "Dealing with $($App)" -Verbose
if ($p.'Path' -match '%SYSTEMDRIVE%\\') {
Write-Verbose "$($App) has a wrong path set in the registry" -Verbose
$v = $p.Path
try {
Set-ItemProperty -Path "$($_.PsPath)" -Name 'Path' -ErrorAction Stop -Value $v -Type ExpandString
} catch {
Write-Warning -Message "Failed to fix $($App) because $($_.Exception.Message)"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment