PowerShell v3 Function Set IEStartPage

Another spin off of the Scripting Guys post,
Hey, Scripting Guy! How Can I Change My Internet Explorer Home Page?
gave me this function for setting the IE start page:
function Set-IEStartPage
{
       [CmdletBinding()]
       param(
             [String]
             $StartPage = about:Blank
       )
      
       if((Get-IEStartPage) -ne $StartPage)
       {
             Write-Verbose "$(Get-TimeStamp): Attempting to set IE start page to $StartPage.";
             Set-ItemProperty -Path HKCU:SoftwareMicrosoftInternet ExplorerMain -Name Start Page -Value $StartPage
            
             if((Get-IEStartPage) -ne $StartPage)
             {
                    Write-Error "$(Get-TimeStamp): The IE start page has not been set to $StartPage.";
             }
             elseif((Get-IEStartPage) -eq $StartPage)
             {
                    Write-Verbose "$(Get-TimeStamp): The IE start page has been set to $StartPage.";
             }
       }
       else
       {
             Write-Verbose "$(Get-TimeStamp): The current IE Home Page already matches $StartPage.";
       }
}

Related Posts by Categories

0 comments:

Post a Comment