Skip to content

Instantly share code, notes, and snippets.

View inamesh's full-sized avatar
🚀
Accelerated learning!

Animesh Rawal inamesh

🚀
Accelerated learning!
View GitHub Profile
@inamesh
inamesh / keepawake.ps1
Last active November 18, 2020 12:41 — forked from jamesfreeman959/keepawake.ps1
A very simple PowerShell script to keep a Windows PC awake and make lync think the user is active on the keyboard
# Useful references:
#
# https://superuser.com/questions/992511/emulate-a-keyboard-button-via-the-command-line
# https://ss64.com/vb/sendkeys.html
# https://social.technet.microsoft.com/Forums/windowsserver/en-US/96b339e2-e9da-4802-a66d-be619aeb21ac/execute-function-one-time-in-every-10-mins-in-windows-powershell?forum=winserverpowershell
# https://learn-powershell.net/2013/02/08/powershell-and-events-object-events/
#
# Removed the while loop. The script will be invoked by Task Scheduler either on schedule or basedon the event "4802" from "Security-Auditing"
$wsh = New-Object -ComObject WScript.Shell
$wsh.SendKeys('+{F15}')
@inamesh
inamesh / BatteryLimiter.ps1
Created June 18, 2020 09:49
Keep laptop battery charged between 50 to 80% (or other custom limits). At home/office it can turn off the smart plug that the charger is connected to, and while away it will popup a message when the specified limit is breached. Home/away is detected using the Wireless network name.
#
#
##************************************* INFO SECTION *******************************
#
#
# This script tests the current battery status and uses that information to :
# a) AT HOME: Turn the smart Plug on/off
# b) AWAY: Alert the user
# See all available battery info using Get-wmiobject win32_battery |Format-List *
# win32_battery documentation here: https://docs.microsoft.com/en-us/windows/desktop/cimwin32prov/win32-battery
@inamesh
inamesh / RemoveDefaultKeyboard.ps
Created June 18, 2020 09:45
When you have multiple languages configured and are using alternative English keyboards, the US English keyboard keeps being added automatically, This unnecessarily complicates language swithching, but can easily be solved if you have admin permissions.
reg delete "HKEY_USERS\.DEFAULT\Keyboard Layout\Preload" /f
#This and other solutions here:
#https://superuser.com/questions/1092246/how-to-prevent-windows-10-from-automatically-adding-keyboard-layouts-i-e-us-ke
@inamesh
inamesh / Microsoft.PowerShell_profile.ps1
Last active June 18, 2020 09:42
alias function to elevate powershell from command line
Function elevate {Start-Process PowerShell -Verb RunAs}
Function q{exit}
@inamesh
inamesh / .profile
Created June 18, 2020 09:36
Avoid running ssh agent and attaching keys every time on Raspberry Pi
#Helper script from GitHub
# source: https://github.com/wwalker/ssh-find-agent
# (blog: http://blog.joncairns.com/2013/12/understanding-ssh-agent-and-ssh-add/)
#- Used in the 'Actions' section
. ~/scripts/ssh-find-agent.sh
## Setup outbound SSH. Run ssh agent and add keys
# This is only needed if agent is not running (e.g. after a reboot)
sshout () {