Skip to content

Instantly share code, notes, and snippets.

View ConnorGriffin's full-sized avatar

Connor Griffin ConnorGriffin

View GitHub Profile
@ConnorGriffin
ConnorGriffin / GDriveUploadExcerpt.ps1
Last active January 18, 2018 21:32
Google Drive Upload Excerpt
<#
This is a fairly simple one-time upload with no options, etc. Consider using this as a base to create a New-GDriveItem type function
Modified code, in response to: https://monteledwards.com/2017/03/05/powershell-oauth-downloadinguploading-to-google-drive-via-drive-api/
You should follow the above link to set $accessToken to your access token and understand what is happening here
#>
# Change this to the file you want to upload
$SourceFile = 'C:\Path\To\File'
# Get the source file contents and details, encode in base64
@ConnorGriffin
ConnorGriffin / Set-NessusFolderScanSchedule.ps1
Created March 12, 2018 19:34
Script to schedule Nessus scans based around the Microsoft patch cycle
<#
.SYNOPSIS
Schedule Nessus scans based around the Microsoft patch cycle
#>
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)][String]$ComputerName,
[Int]$Port = 8834,
[Parameter(Mandatory=$true)][String]$ScanFolder,
@ConnorGriffin
ConnorGriffin / Edit-NessusScanDetail.ps1
Last active March 12, 2018 22:21
Edit nessus scan details, including schedule, name, and policy data, extracted of Scan.ps1 from Posh-Nessus
<#
.Synopsis
Edit nessus scan details, including schedule, name, and policy data
.DESCRIPTION
Long description
.EXAMPLE
Example of how to use this cmdlet
.EXAMPLE
Another example of how to use this cmdlet
#>
@ConnorGriffin
ConnorGriffin / GDrive.Upload.ps1
Last active May 27, 2024 08:11
GDrive Upload PowerShell Script
# Set the Google Auth parameters. Fill in your RefreshToken, ClientID, and ClientSecret
$params = @{
Uri = 'https://accounts.google.com/o/oauth2/token'
Body = @(
"refresh_token=$RefreshToken", # Replace $RefreshToken with your refresh token
"client_id=$ClientID", # Replace $ClientID with your client ID
"client_secret=$ClientSecret", # Replace $ClientSecret with your client secret
"grant_type=refresh_token"
) -join '&'
Method = 'Post'
@ConnorGriffin
ConnorGriffin / Get-RedditPatchTuesdayKBMentions.ps1
Created March 29, 2018 00:10
Outputs a table of any comments that mention a KB number on the reddit.com/r/sysadmin monthly Patch Tuesday megathread
# Get a list of posts from reddit.com/r/sysadmin front page
$posts = Invoke-RestMethod 'https://www.reddit.com/r/sysadmin/.json'
# Get the URL for the patch tuesday megathread
$megathread = $posts.data.children.data.Where{$_.title -like '*Patch Tuesday Megathread*'}
$megathreadUrl = $megathread.Url
# Get the comments of the megathread
$comments = Invoke-RestMethod "$megathreadUrl.json"
@ConnorGriffin
ConnorGriffin / ecobeeSmartHomeAway.js
Last active April 27, 2018 21:19
Home Assistant Node-RED Scripts
var homeStatus = msg.payload.data.state
var homeStatusMinutes = Math.floor((msg.payload.timeSinceChangedMs/1000)/60)
var notHome = (homeStatus == "not_home" && homeStatusMinutes >= 10)
var ecobeeStatus = flow.get("ecobeeStatus")
var holdMode = ecobeeStatus.data.attributes.hold_mode
var climateMode = ecobeeStatus.data.attributes.climate_mode
var operationMode = ecobeeStatus.data.attributes.operation_mode
// Set the holdMatch criteria based on whether we're home or not, this is so we don't cancel temp or vacation holds
@ConnorGriffin
ConnorGriffin / ConvertFrom-Hsl.ps1
Last active July 26, 2018 18:08
Powershell script to convert HSL to RGB
function ConvertFrom-Hsl {
param(
$Hue,
$Saturation,
$Lightness,
# Return in ConEmu.xml ABGR hex format
[Switch]$ABGR
)
function ToHex ($c) {
@ConnorGriffin
ConnorGriffin / Get-SrpUsage.ps1
Last active December 4, 2019 20:44
Get SRP (Salt River Project) power usage per hour using PowerShell
# Set the SRP base url and get yesterday's date in a format that the report expects
$baseUrl = 'https://myaccount.srpnet.com'
$yesterday = (Get-Date).AddDays(-1).ToString('M/d/yyyy')
# Start a session, pull the form data
$r = Invoke-WebRequest $baseUrl -SessionVariable session
# Identify the username/password form
$loginForm = $r.Forms.Where{$_.Fields.Keys -contains 'UserName'}
@ConnorGriffin
ConnorGriffin / ynabReport.gs
Last active October 22, 2019 14:24
YNAB Weekly Spending Report - Google Script (Standalone)
// YNAB Weekly Spending Report sending script
function sendYnabReport() {
// Set our options
var accessToken = 'token goes here' // Your YNAB Personal Access Token
var budgetName = "Connor's Budget" // Budget name to use, in case you have multiple budgets
var categories = ['Fast Food', 'Groceries'] // Your desired category names to monitor, in Javascript array syntax
var recipient = '[email protected], [email protected]' // Email recipients, comma separated
var url = 'https://api.youneedabudget.com/v1'
var headers = {
@ConnorGriffin
ConnorGriffin / GoogleDrive.SheetExport.ps1
Created July 14, 2018 00:00
Google Sheets Export to PowerShell Object by GID (Sheet Tab ID)
# Set our options
$RefreshToken = ''
$ClientID = ''
$ClientSecret = ''
$spreadsheetId = '' # Get this from the URL: https://docs.google.com/spreadsheets/d/{spreadsheetId}
$sheetId = '' # Get this from gid= in the URL
# Set the Google Auth parameters
$params = @{
Uri = 'https://accounts.google.com/o/oauth2/token'