How to lock the homepage in Internet Explorer (PowerShell)

Introduction
This script shows how to lock the homepage in Internet Explorer.

Scenarios
Some applications will change customers' IE homepage.  This script is to lock IE homepage.

Script

Step 1: Right Click the script and select Run with PowerShell.

 

Step 2: Then there will be a dialog. If you want to lock current homepage, then press enter to continue. Otherwise enter the web site address you want to lock and press enter to continue.

 

Here are some code snippets for your references

PowerShell
Edit|Remove
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) 
{    
$arguments = "& '" + $myinvocation.mycommand.definition + "'" 
Start-Process powershell -Verb runAs -ArgumentList $arguments 
Break 
} 
  
#Registry path  
$homepath = "HKCU:\Software\Microsoft\Internet Explorer\Main" 
#Homepage address 
$homepage = (get-ItemProperty -Path $homepath -Name "start page").{Start page} 
  
#Confirm locking homepage 
$choice = Read-Host "Do you want to lock $homepage as IE homepage?(If yes press ENTER, otherwise enter the site you want to set as homepage )" 
if($choice -ne ""{ 
     
    Set-ItemProperty -Path  $homepath -Name "Start page" -Value $choice 
    $homepage = $choice 
} 
  
#Modify registry 
$path =  "HKCU:\Software\Policies\Microsoft\Internet Explorer\Control Panel" 
  
Remove-Item -Path "HKCU:\Software\Policies\Microsoft\Internet Explorer"  -Confirm:$false -Recurse 
  
New-Item -Path "HKCU:\Software\Policies\Microsoft\Internet Explorer" -ErrorAction SilentlyContinue | Out-Null 
  
New-Item -path  $path -ErrorAction SilentlyContinue | Out-Null 
  
New-ItemProperty -Path $path -Name "HomePage" -Value 1 -PropertyType String | Out-Null 
  
Write-Host "Lock $homepage as IE homepage successfully." -ForegroundColor Green 
  
cmd /c pause 

Prerequisite

Windows 8

 

Microsoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.