Skip to content

Instantly share code, notes, and snippets.

View kiwi-cam's full-sized avatar

Cameron kiwi-cam

View GitHub Profile
@kiwi-cam
kiwi-cam / mi_temp.sh
Last active January 2, 2022 13:46
A bash script to read BLE temperature sensors and push values to MQTT/File. Requires a "sensors" file (line 6) which is a CSV list with MACADDRESS,NAME,OUTPUTFILE.
#!/bin/bash
mqtt_topic="mi_temp"
mqtt_ip="localhost"
sensors_file="/usr/lib/mi_temp/sensors"
handler()
{
logger -p 6 --tag=mitemp "Closing HCI device"
@kiwi-cam
kiwi-cam / personFinder.sh
Last active November 16, 2023 22:24
Using WyzeCam Hacks (https://github.com/HclX/WyzeHacks) with Azure Vision API and rclone for Uploads
#!/bin/bash
####### Configuration #####
# Azure Setup: https://docs.microsoft.com/en-us/azure/cognitive-services/cognitive-services-apis-create-account?tabs=multiservice%2Cwindows
AzureSubscriptionKey=""
AzureEndpoint=""
# IFTTT Setup: https://ifttt.com/maker_webhooks
IFTTTKey=""
IFTTTEventName=""
@kiwi-cam
kiwi-cam / HomebridgeBackup.sh
Created June 12, 2020 02:13
A simple bash script to email details of your Homebridge setup for backup/archiving. Takes a single argument, the email destination. Uses sendmail so some configuration may be required. Also assumes config.json is in /var/homebridge
#!/bin/bash
if ! [[ "$1" =~ ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$ ]]
then
echo "Email address $1 is invalid."
exit 1
fi
npm=`npm list -g --depth=0 | sed 's/$/<br \/>/'`
config=`cat /var/homebridge/config.json | sed 's/$/<br \/>/'`
@kiwi-cam
kiwi-cam / Get-Holiday.ps1
Last active February 4, 2019 22:11
Uses information from NZ Government to identify if a date is a New Zealand public holiday.
<#
.Synopsis
Uses information from NZ Government to identify if a date is a New Zealand public holiday.
.DESCRIPTION
This script pulls the lastest iCal from employment.govt.nz to confirm if a date is a public holiday.
If a public holiday is found, it's name is returned.
There is an assumption that the holidays supplied are single day events.
.PARAMETER Date
The date to be checked.
@kiwi-cam
kiwi-cam / Start-RobocopyBackup.ps1
Last active February 4, 2019 22:09
This script runs Robycopy to duplicate a source and destination drive for backups. It then parses the results and emails admins.
[CmdletBinding()]
param()
#Main Variables adjusted
$Dest = "F:\"
$LogFile = "C:\Admin\RobocopyBackup.log"
$ReportTo = @("admin1@Company.co.nz","admin2@Company.co.nz")
$LogSummary = ""
$Region = "Auckland"
@kiwi-cam
kiwi-cam / Get-DCSecurityLogs.ps1
Last active August 14, 2018 22:11
This script will query your forest for a list of all Domain Controllers. It'll then connect to the C$ share on each server and get a copy of Security.evtx from C:\Windows\System32\Winevt\Logs\
<#
.Synopsis
Gathers the Security.evtx files from each DC in your Forest
.DESCRIPTION
This script will query your forest for a list of all Domain Controllers. It'll then connect to the C$ share on each server and
get a copy of Security.evtx from C:\Windows\System32\Winevt\Logs\. These will then be output to the folder supplied as OutputFolder
.PARAMETER OutputFolder
Required - The folder where the evtx files should be collected.
.EXAMPLE
./Get-DCSecurityLogs.ps1 E:\LogFiles\
@kiwi-cam
kiwi-cam / Get-LogonEvents.ps1
Last active August 21, 2018 20:37
This script uses LogParser 2.2 from Microsoft to to build a list of logon events that match some predefined searches. Supply a path to EventPath which contains the evtx files you'd like to scan. You'll want to grab Security.evtx from C:\Windows\System32\WinEvt\Logs on all servers to scan, or use this script to automate grabbing them: https://gis…
<#
.Synopsis
Crawls evtx files and gathers events based on predefined searches.
.DESCRIPTION
This script uses LogParser 2.2 from Microsoft to to build a list of logon events.
Supply a path to EventPath which contains the evtx files you'd like to scan. You'll want to grab Security.evtx from
C:\Windows\System32\WinEvt\Logs on all servers to scan.
.PARAMETER LogParserLocation
The full path to logparser.exe
@kiwi-cam
kiwi-cam / PasswordStorage.vbs
Last active July 31, 2018 00:31
PowerShell includes tools to Encrypt and Decrypt strings. Because we're not supplying a Key, they're encrypted using Windows Data Protection API (DPAPI) meaning the string can only be decrypted on the computer used to encrypt them. These one line commands can be used to output to file, then recover the password securely
'Powershell OneLiner to encrypt a password to file:
' ConvertTo-SecureString -String "ThisIsMySecurePassword" -AsPlainText -Force | ConvertFrom-SecureString > .\Password.txt
'Powershell OneLiner to decrypt that password
' (New-Object PSCredential "user",(ConvertTo-SecureString (Get-Content .\Password.txt))).GetNetworkCredential().Password
'You could then embed this into VBScript so the password is not stored in the script
'powershell.exe -NonInteractive -NoLogo -Command "(New-Object PSCredential 'user',(ConvertTo-SecureString (Get-Content .\Desktop\Password.txt))).GetNetworkCredential().Password"
Set oShell = WScript.CreateObject("WScript.Shell")
@kiwi-cam
kiwi-cam / Initialise-RAWDisks.ps1
Created July 29, 2018 23:35
Scans for RAW drives attached to the computer and formats them. Drive Letters are assigned sequentially from D:\ on, except on computers with SQL in the Computer name where Drive 2 will become L drive for Logs.
<#
.Synopsis
Scans for RAW drives attached to the computer and formats them.
.DESCRIPTION
Drive Letters are assigned sequentially from D:\ on, except on computers with SQL in the Computername where
Drive 2 will become L drive for Logs. Subsequent drives are lettered sequentially.
.PARAMETER UnitSize
An Int specifying the AllocationUnitSize used when formatting
.PARAMETER FileSystem
Specifies the file system with which to format the volume. The acceptable values for this parameter are:NTFS,
@kiwi-cam
kiwi-cam / Start-Monitoring.ps1
Last active October 26, 2023 05:07
A simple Powershell script that monitors a remote hosts connection. Loops constantly reporting to the screen when the status changes. Optionally also records to the event log, makes an audible beep, and/or sends emails.
<#
.SYNOPSIS
Tests the connection to the supplied host or IP and reports back on changes to its status.
.DESCRIPTION
This script will check the connection to the supplied hostname or IP address every 5 second's to
monitor its status. If the status changes, a message is recorded, the Eventlog is update (optional), and an email is sent
to a supplied email address (optional).
If a TCPPort parameter is suppied the script will attempt to connect to this port. Otherwise a simple ICMP Ping is used.