[How-To] Powershell okienko – part 1

On 7. júla 2011, in How To, by admin

Enable / Disable Proxy + Restart IE and set-up Homepage

if ((Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -Name ProxyEnable | Select-Object ProxyEnable).ProxyEnable -eq 0)
{
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -Name ProxyEnable -Value 1
$Message = "Proxy Enabled`n"
$Message = $Message + ((Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' | Select-Object ProxyServer).ProxyServer) + "`n"
}
else
{
Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -Name ProxyEnable -Value 0
$Message = "Proxy Disabled`n"
}
if ((get-process iexplore -erroraction silentlycontinue) -eq $null)
{}
else
{
Stop-Process -Name iexplore -PassThru
$Message = $Message + "`n- Restarting a browser.`n"

$IEStartPage = (Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Internet Explorer\Main' -Name "Start Page" | Select-Object "Start Page").'Start Page'
$IEApp = New-Object -ComObject InternetExplorer.Application
$IEApp.Navigate("$IEStartPage")
$IEApp.Visible = $true

$Message = $Message + "`nHome page: " + $IEStartPage
}
Start-Sleep -seconds 2

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.VisualBasic")
[Microsoft.VisualBasic.Interaction]::MsgBox("Status: $Message","OkOnly,Information", "Information")

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Facebook
  • LinkedIn
  • Twitter
 

Leave a Reply

WordPress Themes

*

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Free WordPress Themes