Skip to content

Instantly share code, notes, and snippets.

@nigamankit7
nigamankit7 / Autosync SyncTool.ps1
Last active March 4, 2022 15:28
a powershell script which I scheduled with task scheduler while booting. This script keeps on running like a deamon and keep on checking for the USB connection. Once the correct USB is connect with predefined name, it starts the sync tool and start syncing for each partnership sequentially. One more benefit is that this script keeps on running …
clear
$scriptpath = $MyInvocation.MyCommand.Path
$dir = Split-Path $scriptpath
$TARGETDIR = $dir + "\log"
if(!(Test-Path -Path $TARGETDIR ))
{
New-Item -ItemType directory -Path $dir -Name "log"
}
$logFile = $TARGETDIR + "\sync.log"
@nigamankit7
nigamankit7 / time.sh
Last active August 29, 2015 14:09
This is a job which will run on the raspberry pi start up and will check current time. If between 5 AM - 8 AM then it will download the hindu newspaper
#!/bin/sh
currentTime=`date +%k%M`
check_time_to_run()
{
tempTime=$1
if [ $tempTime -gt 630 -a $tempTime -lt 800 ]; then
echo "Time is between 5 AM and 8 AM. Running Fetch_news.sh."
sudo sh /home/pi/scripts/fetch_news.sh
else
echo "This is not between 5 AM and 8 AM. ABORTING !"
@nigamankit7
nigamankit7 / piip.sh
Created November 9, 2014 16:04
When Raspberry Pi starts it will send it IP via PushBullet notification
#!/bin/bash
ipVar=$(/sbin/ifconfig $(netstat -nr | tail -1 | awk '{print $NF}') | awk -F: '/inet /{print $2}' | cut -f1 -d ' ')
curl https://api.pushbullet.com/v2/pushes \
-u <API>: \
-d device_iden="<ID>" \
-d type="note" \
-d title="Pi IP address" \
-d body=$ipVar \
-X POST
@nigamankit7
nigamankit7 / Get_Hostname_For_Unmanaged_Dectector.ps1
Created July 9, 2014 04:43
Reads a list of IPs and check their hostname. Save it in seperate files - resolved and unresolved
Clear
$scriptpath = $MyInvocation.MyCommand.Path
$dir = Split-Path $scriptpath
$source = $dir + "\IPlist.txt"
$computers= gc $source
$DNS_Resolve = $dir + "\DNS_Resolved.csv"
Clear-Content $DNS_Resolve -ErrorAction "SilentlyContinue"
$DNS_Unresolve = $dir + "\DNS_Unesolved.csv"
Clear-Content $DNS_Unresolve -ErrorAction "SilentlyContinue"
@nigamankit7
nigamankit7 / notify.py
Last active December 31, 2015 06:39
This script is to send notification to pushbulllet when download compeltes in transmission
#!/usr/bin/python
import sys
from pushbullet import Device
apiKey = "#########################"
phone = Device(apiKey, ################)
torrentname = '\n'.join(sys.argv[1:])
push = phone.push_note('Transmission: New download completed',torrentname + ' has been downloaded')
@nigamankit7
nigamankit7 / transfinish.sh
Last active December 31, 2015 06:28
Script to send pushover notification from Transmission after download complete
#!/bin/sh
curl -s \
-F "token=APP_TOKEN" \
-F "user=USER_TOKEN" \
-F "title=Download Finished" \
-F "message=$TR_TORRENT_NAME: $TR_TIME_LOCALTIME" \
https://api.pushover.net/1/messages > /dev/null
@nigamankit7
nigamankit7 / EmptyAllRecycleBin.ps1
Last active December 13, 2015 21:18
This powershell script for SharePoint 2010 iterate through each site collection in a given web application. First it moves content from each web recycle bin to site collection recycle bin and then delete it from the site collection "Admin Recycle Bin" URL Shortcuts for accessing Recycle bin: /_layouts/recyclebin.aspx - For Web Recycle Bin /_layo…
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$WebApp=get-spwebapplication "http://webapplicationname"
foreach ($SPSite in $webApp.Sites)
{
foreach($SPWeb in $SPSite.AllWebs)
{