Skip to content

Instantly share code, notes, and snippets.

View royashbrook's full-sized avatar

Roy Ashbrook royashbrook

View GitHub Profile
@royashbrook
royashbrook / GetLogOnOffEvents.ps1
Created April 19, 2023 19:40
show logon logoff events for current domain. easier to run from a domain controller.
$Username = "rashbrook" # Replace with the target user's username
$LogName = "Security"
$LogonEventID = 4624
$LogoffEventID = 4634
# Load the Active Directory module
Import-Module ActiveDirectory
# Get the list of domain controllers
$DomainControllers = Get-ADDomainController -Filter *
@royashbrook
royashbrook / Github New.js
Last active March 7, 2022 22:34
Toggl Integration for New Github Projects
// add this to the bottom of the current github integration. have to enable dev mode and click 'edit'
// probably a better selector, but i'm guessing these names aren't 'finished' as this is in beta still
// this one works for now in the board view which is what i needed it to work for.
// New Project Page
togglbutton.render("div[class*='Box-'] div[class*='Box-'] div[class*='Box-'] > a[class*='Link-']:not(.toggl)", { observe: true }, function (
elem
) {
const link = togglbutton.createTimerLink({
className: 'github',
@royashbrook
royashbrook / example.yml
Last active January 14, 2022 19:04
meraki vpn
name: main
on:
workflow_dispatch:
schedule:
- cron: '30 5 * * *' # trigger at 5:30am UTC
jobs:
job1:
runs-on: windows-latest
@royashbrook
royashbrook / notes.md
Last active January 14, 2022 18:28
Git Notes
@royashbrook
royashbrook / Get-FileEncoding.ps1
Created January 10, 2022 21:39
Simple PS script to get encoding on a file using streamreader
function Get-FileEncoding ($FilePath){
New-Object System.IO.StreamReader $FilePath -OutVariable Stream |
Select-Object -ExpandProperty CurrentEncoding |
Select-Object -ExpandProperty BodyName
$Stream.Dispose()
}
// go to devicon.dev and copy/paste this into the browser console or run as a snippet
// note: there are a handful which do not have the name in the standard format so they'll
// need to be manually corrected. this is just meant to make it a little easier.
//selector we'll apply the event to and get icon names from
var sel = "body > div.container > div > ul > li > span > i[class*='devicon']"
// for cleanup so can tweak and just rerun all of this
try {Array.from(document.querySelectorAll(sel)).forEach(x=>x.removeEventListener('click', handleClick)) }catch{}
try {document.querySelector('#mydiv').remove() }catch{}
@royashbrook
royashbrook / filling in an existing spreadsheet.ps1
Created November 22, 2021 15:15
Moving from epplus.dll to import-excel
# this sample is a situation where i have a template file provided by a customer. this file is copied and the copy is then filled up with data. these examples assume epplus is in the working dir so it can be loaded and i am not including the import-module line for importexcel
function old($tfile,$file,$data){
Copy-Item $tfile $file
if($data.count -eq 0){
return
}
@royashbrook
royashbrook / app.js
Created November 17, 2021 22:24
transfer git repo to new owner with js
const { Octokit } = require("@octokit/core")
// you need a personal access token that controls the repos, once you get one, put it down below
const octokit = new Octokit({ auth: `REPLACEME!!!` });
octokit.request('GET /user/repos', {
type: "private",
per_page: "100"
})
.then(x => x
.data
function OhMyPoshStuff{
Import-Module oh-my-posh
Import-Module -Name Terminal-Icons
function Get-ThemeList{
$themeurl = "https://github.com/JanDeDobbeleer/oh-my-posh/tree/main/themes"
$ProgressPreference = 'SilentlyContinue'
$links = (iwr $themeurl).links
$ProgressPreference = 'Continue'
$themes=($links | where title -like *omp.json).title -Replace ".omp.json",""
@royashbrook
royashbrook / migrategitfromazuredevopstogithub.ps1
Created May 5, 2021 17:22
Migrate git repos from Azure Devops to github
# how i moved all of my git repos from azure devops to github
# prereqs
# azure cli - https://docs.microsoft.com/en-us/cli/azure
# github cli - https://cli.github.com/
# note: you can get away with neither of these if you want
# to manually make some lists and repos yourself
# we'll be creating local clones of everything to work with