Script to remove Internet Explorer in Windows 7 (PowerShell)

Introduction

This PowerShell script demo shows how to remove Internet Explorer in Windows 7.

Scenarios

In some situations, customers need to uninstall Internet Explorer 9 to fix crash issue, but they cannot manually uninstall Internet Explorer successfully sometimes.

Script

Step 1: Click Start, type powershell in the search box on the Start Menu, right-click the Windows PowerShell icon, and then click Run Windows PowerShell as administrator. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.

Step 2: Run the script in Windows PowerShell Console , type the one command : Import-Module <Script Path>.

For example, type Import-Module C:\Scripts\RemoveInternetExplorer.psm1

The step is shown in the following figure.

Step 3: You can type the command Get-Help Remove-OSCInternetExplorer -Full to display the entire help file for this function, such as the syntax, parameters,
or examples.


Here are some code snippets for your references. To get the complete script sample, please click the download button at the beginning of this page. 

PowerShell
Edit|Remove
If($Enable) 
{ 
    If($PSCmdlet.ShouldProcess("Enabling Internet Explorer feature")) 
    { 
        If($FeatureState -match "Disabled") 
        { 
            Write-Host "Enabling Internet Explorer feature..." 
            Dism /online /Enable-Feature /FeatureName:Internet-Explorer-Optional-amd64 
        } 
        Else 
        { 
            Write-Warning "Internet Explorer is already Enabled."  
        } 
    } 
}

Example

Example 1: Type the Remove-OSCInternetExplorer command in the Windows PowerShell Console.

This command shows how to uninstall Internet Explorer feature.

Example 2: Type the Remove-OSCInternetExplorer -Enable command in the Windows PowerShell Console.

 This command shows how to install Internet Explorer feature.

 Note You may need to reboot or log off of windows for the change to take effect. 

Prerequisite

Windows PowerShell 2.0

Windows 7