Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [CmdletBinding()]
- param(
- [string][ValidateSet("Remove", "Install")]$Action,
- [switch]$AcceptEULA
- )
- #requires -RunAsAdministrator
- #requires -Version 5
- <#
- .Synopsis
- ReInstall Microsoft Edge -- v1.1 Created by: http://fatt.xyz
- This script will allow you to re-install Microsoft Edge Browser for Windows 10.
- The script MUST be run as administrator to function.
- .DESCRIPTION
- There are two stages that can be run. First, the removal of Edge.
- A reboot is then required. Afterwards, Stage 2 will re-install Edge.
- .EXAMPLE
- Reinstall-Edge.ps1 -Action Reinstall -Verbose
- .NOTES
- http://fatt.xyz/programs/reinstall-microsoft-edge/
- #>
- $Host.UI.RawUI.WindowTitle = "REINSTALL MICROSOFT EDGE v1.1"
- Write-Output "This script is provided for free use and contains ABSOLUTELY ZERO WARRANTY!
- By using this script, you accept all liability of anything that may happen.
- Use it at your own risk. FATT.XYZ are under zero obligation to address
- issues that may arise during the use, or misuse, of this script. You, the
- user, are solely responsible for any outcomes of the use of this script.
- To use this script, you must agree to these conditions.
- Additionally, please keep in mind that THIS WILL DELETE ALL BROWSER DATA
- FROM EDGE including but not limited to favorites, saved passwords, cookies,
- history, settings, and site data. Please ensure you backup this data
- before running this script if it is needed. By proceeding, you acknowledge
- that you are aware that all of your Edge data will be permanently lost."
- while (!$AcceptEULA) {
- $eulaInput = Read-Host "`nType 'I AGREE' in capitals to proceed. By proceeding you agree to the conditions above. Type 'exit' to cancel the script."
- if ($eulaInput -eq 'I AGREE') {$AcceptEULA = $true}
- elseif ($eulaInput -eq 'exit') {exit}
- }
- Write-Verbose "Checking if machine is running Windows 10."
- $cimQuery = Get-CimInstance -Namespace root\cimv2 -ClassName Win32_OperatingSystem
- if ($cimQuery.Caption -like "Microsoft Windows 10*") {
- Write-Verbose "The machine is running Windows 10."
- } else {
- Write-Error "The operating system running on this machine is not supported by this script.
- Only Windows 10 is supported."
- exit
- }
- #check if Edge is present
- $edgeCheck = (Test-Path -Path "$env:USERPROFILE\AppData\Local\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe")
- Function Remove-Edge {
- Write-Verbose "Checking if Edge is installed."
- if ($edgeCheck -eq $true) {
- Write-Error "Edge is present, removing Edge"
- } else {
- Write-Verbose "Edge is not present. Exiting script."
- exit
- } #if
- Write-Verbose "Closing all instances of Edge."
- Get-Process microsoftedge | Stop-Process -Force
- Write-Verbose "Removing Edge folder."
- Remove-Item -Path $env:USERPROFILE\AppData\Local\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe -Recurse
- Write-Warning "The computer needs to reboot. Relaunch the script and select '-Action Install' after reboot if Edge is to be reinstalled."
- Restart-Computer -Confirm
- }
- Function Install-Edge {
- Write-Verbose "Checking if Edge is installed."
- if ($edgeCheck -eq $true) {
- Write-Error "Edge is present. Exiting script."
- exit
- } else {
- Write-Verbose "Edge is not present, installing Edge."
- }
- Get-AppXPackage -AllUsers -Name Microsoft.MicrosoftEdge ^ |
- ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register ^"$($_.InstallLocation)\AppXManifest.xml^" -Verbose}
- }
- #run whatever was specified in $Action
- switch ($Action) {
- Remove {Remove-Edge}
- Install {Install-Edge}
- Default {
- if ($edgeCheck -eq $true) {
- Remove-Edge
- } else {
- Install-Edge
- } #if
- } #default
- } #switch
Advertisement
Add Comment
Please, Sign In to add comment