Skip to content

Instantly share code, notes, and snippets.

View bmcguirk's full-sized avatar

Brian J. McGuirk bmcguirk

View GitHub Profile
@bmcguirk
bmcguirk / get_applications_per_machine.ps1
Created December 19, 2019 15:29
Powershell script to get all the machines in a particular OU and then get all the programs installed on those machines.
# A Powershell Script to Get AD Machines from a certain OU and then query/export a CSV of their installed software inventory.
# 2019-10-17 - v1 - Author: Brian McGuirk - The Script works, but could maybe use a progress bar. Next up.
# 2019-11-14 - v2 - Author: Brian McGuirk - Added a progress bar. Limited properties to just useful ones. I think.
# Pre-requisites:
# - The Active Directory Powershell modules. In Windows 10, this should be an enable-able "Optional Feature."
# - The target machines must WMI enabled.
# Go here for more information: https://docs.microsoft.com/en-us/windows/win32/wmisdk/wmi-start-page
Write-Host "Starting Inventory Script..."
# THE SCRIPT
@bmcguirk
bmcguirk / clearcurrent.json
Last active September 25, 2018 14:39
Jupyterlab Keyboard Shortcut to Clear Current Cell Output
// Need to paste into "User Overrides" section of "Advanced Settings Editor" in JupyterLab.
// Source of name of command from editmenu:
// https://github.com/jupyterlab/jupyterlab/blob/3ea6a39264f44694febc9357578ffcb43b4f1780/packages/mainmenu-extension/src/index.ts#L42
{
"editmenu:clear-current": {
"command": "editmenu:clear-current",
"keys": [
"Ctrl Shift O"
],
@bmcguirk
bmcguirk / imgs_to_gif.py
Created August 2, 2018 15:03
Convert images in a directory to a gif.
# Converts a bunch of images into a gif.
# Relies on Pillow and glob
from PIL import Image
import glob
# Glob to regex the right files. Returns a list.
png_files = glob.glob("*.png")
# Bulk-open selected images.
ims = [Image.open(i) for i in png_files]
@bmcguirk
bmcguirk / bash_prompt.sh
Created August 23, 2016 19:34 — forked from insin/bash_prompt.sh
Set color bash prompt according to active virtualenv, git branch and return status of last command.
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch/status of the current git repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.
@bmcguirk
bmcguirk / find_404s_using_wget.sh
Last active February 4, 2024 13:48
Find broken links (404s) via wget and grep.
# Full credit to Pete here: http://www.createdbypete.com/articles/simple-way-to-find-broken-links-with-wget/
wget --spider -nd -o ~/wget.log -e robots=off -w 1 -r http://www.example.com
grep -B 2 '404' example.com.log >> example.com.404.log
@bmcguirk
bmcguirk / install_windows_10_ad_powershell_module.ps1
Last active December 17, 2019 16:59
Install the Active Directory PowerShell Module on Windows 10
# Complete credit to Microsoft here: https://blogs.technet.microsoft.com/ashleymcglone/2016/02/26/install-the-active-directory-powershell-module-on-windows-10/
# And Here: https://gallery.technet.microsoft.com/Install-the-Active-fd32e541
# Script follows:
#requires -RunAsAdministrator
<#-----------------------------------------------------------------------------
Ashley McGlone, Microsoft Premier Field Engineer
http://aka.ms/goateepfe
February 2016
Install-ADModule
@bmcguirk
bmcguirk / find_sharepoint_sites.ps1
Created August 11, 2016 14:17
Find All Sharepoint Sites on Local Network - Sharepoint PS Module Not Required
# Because they pop up like crazy and are often not well-maintained, which is just kind of asking for something awful to happen.
# I didn't write this script, but you can see the original blog post here:
# http://www.wildwires.com/blog/12-02-24/finding_every_server_that_has_sharepoint_installed.aspx
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.Filter = '(OperatingSystem=Window*Server*)'
"Name","canonicalname","distinguishedname" | Foreach-Object {$null = $objSearcher.PropertiesToLoad.Add($_) }
$names = $objSearcher.FindAll() | Select-Object @{n='Name';e={$_.properties['name']}},@{n='ParentOU';e={$_.properties['distinguishedname'] -replace '^[^,]+,'}},@{n='CanonicalName';e={$_.properties['canonicalname']}},@{n='DN';e={$_.properties['distinguishedname']}}
$names | forEach-object{$_.name + "`n" + "=================="; get-wmiobject -computerName $_.name -class win32_product | where {$_.Name -eq "Microsoft SharePoint Server 2010 "}; "`n"; "`n"}

Keybase proof

I hereby claim:

  • I am bmcguirk on github.
  • I am brianjmcguirk (https://keybase.io/brianjmcguirk) on keybase.
  • I have a public key whose fingerprint is 48CC 09B7 1096 5112 A69B DF70 F004 6168 B4EC C058

To claim this, I am signing this object:

@bmcguirk
bmcguirk / gist:c0d0e5b9ee0e6c0cadaf
Created July 8, 2015 21:13
mkdir - Multiple Directories

I found this super useful, so I'm reposting directly from Matt Butcher's site:

Often times, I want to create a full directory structure, and I'd like to do it with just one call to mkdir. That is, I want to create a root directory and multiple subdirectories all at once. Here's how to do this.

mkdir -p myProject/{src,doc,tools,db}

The above creates the top-level directory myProject, along with all of the subdirectories (myProject/src, myProject/doc, etc.). How does it work? There are two things of note about the command above:

  • The -p flag: This tells mkdir to create any leading directories that do not already exist. Effectively, it makes sure that myProject gets created before creating myProject/src.