Skip to content

Instantly share code, notes, and snippets.

@Biggy1606
Last active February 4, 2022 12:29
Show Gist options
  • Save Biggy1606/a5e117d6585289ce7942163f6f916444 to your computer and use it in GitHub Desktop.
Save Biggy1606/a5e117d6585289ce7942163f6f916444 to your computer and use it in GitHub Desktop.
Windows Scripts
@echo off
git config --global --unset-all user.name
git config --global --unset-all user.email
git config --local --unset-all user.name
git config --local --unset-all user.email
@pause
[CmdletBinding()]
param (
[Parameter()]
[Int32]
$option
)
$reg = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
$settings = Get-ItemProperty -Path $reg
$isProxyEnable = $settings.ProxyEnable
function ShowProxyState {
if ($settings.ProxyEnable) {
Write-Output ' Status: ON'
}
else {
Write-Output ' Status: OFF'
}
' ' + 'Address:' + $settings.ProxyServer
}
function ChangeProxyState {
if ($isProxyEnable -eq 1) {
Set-ItemProperty -Path $reg -Name ProxyEnable -Value 0
Write-Output ' Proxy Disabled'
}
elseif ($isProxyEnable -eq 0) {
Set-ItemProperty -Path $reg -Name ProxyEnable -Value 1
Write-Output ' Proxy Enabled'
}
}
function ChangeProxyAddress {
$address = Read-Host 'New proxy address [ip:port] '
Set-ItemProperty -Path $reg -Name ProxyServer -Value $address
}
if ($option -ne '') {
switch ($option) {
1 { ShowProxyState }
2 { ChangeProxyState }
3 { ChangeProxyAddress }
Default { 'Bad option' }
}
}
else {
while ($select -ne 'q') {
$reg = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
$settings = Get-ItemProperty -Path $reg
$isProxyEnable = $settings.ProxyEnable
Write-Output "[1] Proxy Status"
Write-Output "[2] Proxy ON/OFF"
Write-Output "[3] Proxy change address"
Write-Output "[q] Exit"
$select = Read-Host 'Select option'
if ($select -eq 1) {
ShowProxyState
}
elseif ($select -eq 2) {
ChangeProxyState
}
elseif ($select -eq 3) {
ChangeProxyAddress
}
elseif ($select -eq 'q') {
Write-Output 'Exiting...'
}
else {
Write-Output " Bad option!"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment