Skip to content

Instantly share code, notes, and snippets.

View realchrisolin's full-sized avatar

Chris Olin realchrisolin

View GitHub Profile
@realchrisolin
realchrisolin / InstallHPUniversalPrinterDriver.ps1
Last active May 7, 2025 14:38
Powershell script to install HP Universal Printer Driver silently / unattended
# Setup temp directory
$prep_dir = "C:\Windows\Temp"
if (-not (Test-Path $prep_dir)) {
New-Item -Path $prep_dir -ItemType Directory -Force | Out-Null
}
Start-Transcript -Path "$($prep_dir)\InstallHPUniversalPrinterDriver.log"
# Find the latest UPD archive file based on version
$updArchives = Get-ChildItem -Path . -Filter "upd-pcl6-x64-*.zip"
@realchrisolin
realchrisolin / script.ps1
Created April 21, 2025 13:05
fetch and install Windows Updates using COM API objects in powershell
# Copy and paste this script into an admin powershell window
# or download it and call it with powershell.exe -ExecutionPolicy Bypass -File /path/to/script.ps1
# API documentation can be found at https://learn.microsoft.com/en-us/windows/win32/wua_sdk/portal-client
# Create a Windows Update session and searcher
$Session = New-Object -ComObject Microsoft.Update.Session
$Searcher = $Session.CreateUpdateSearcher()
# Search for updates with progress
@realchrisolin
realchrisolin / reference.ps1
Created February 18, 2025 18:53
Powershell / CMD Sysadmin Cheatsheet of Awesome
Set-LocalUser -Name "$user" -Password (ConvertTo-SecureString "examplepassword123" -AsPlainText -Force)
@realchrisolin
realchrisolin / script.ps1
Last active February 20, 2025 14:38
fetch combined successful interactive and non-interactive M365 sign-ins for the last month via Graph API
# This script is meant to be run directly in a powershell 7 shell (parts of it are not powershell 5 compatible)
# ADJUST THE FILTER STRING TO PULL THE SIGN-IN RECORDS YOU WANT FIRST, DO NOT ASSUME IT WILL WORK OUT-OF-THE-BOX
Import-Module Microsoft.Graph.Authentication
Import-Module Microsoft.Graph.Beta.Reports
try {
Connect-MgGraph -Scopes "AuditLog.Read.All", "Organization.Read.All", "Policy.Read.All" -ContextScope Process
Write-Host "Successfully connected to Microsoft Graph" -ForegroundColor Green
$tenantName = Get-MgBetaOrganization | Where-Object { $_.Id -eq $($(Get-MgContext).TenantId) } | Select-Object -ExpandProperty DisplayName
This file has been truncated, but you can view the full file.
{
"openapi": "3.0.1",
"info": {
"title": "Connectwise Manage Public Endpoints",
"version": "2024.13"
},
"servers": [
{
"url": "http://na.myconnectwise.net/v4_6_release/apis/3.0"
}
This file has been truncated, but you can view the full file.
{
"openapi": "3.0.1",
"info": {
"title": "Connectwise Manage Public Endpoints",
"version": "2024.13"
},
"servers": [
{
"url": "http://na.myconnectwise.net/v4_6_release/apis/3.0"
}
@realchrisolin
realchrisolin / ip_lookup.py
Last active January 15, 2025 16:13
Microsoft 365 sign-in log IP lookup tool
import base64
import os
import sys
import pandas as pd
from bs4 import BeautifulSoup
import io
import requests
import time
from typing import List, Optional, Dict, Tuple
import logging
@realchrisolin
realchrisolin / RunWindowsUpdates.ps1
Last active November 27, 2024 22:13
unattended Windows Update scripts compatible with Windows Provisioning Packages
# utility script to fetch Windows Updates -- must be run as administrator
# Set execution policy to RemoteSigned for the current process
Set-ExecutionPolicy RemoteSigned -Scope Process -Force
# Install NuGet package provider
Install-PackageProvider NuGet -Force
# Install PSWindowsUpdate module
Install-Module PSWindowsUpdate -Force
00000000 00 00 00 18 66 74 79 70 6d 70 34 32 00 00 00 00 |....ftypmp42....|
00000010 6d 70 34 31 69 73 6f 6d 00 00 00 28 75 75 69 64 |mp41isom...(uuid|
00000020 5c a7 08 fb 32 8e 42 05 a8 61 65 0e ca 0a 95 96 |\...2.B..ae.....|
00000030 00 00 00 0c 31 30 2e 30 2e 31 39 30 34 34 2e 30 |....10.0.19044.0|
00000040 00 00 02 0d 6d 64 61 74 00 00 00 00 00 00 00 10 |....mdat........|
00000050 20 97 6a 97 66 2a 24 44 04 00 00 00 07 1d 2d 2d | .j.f*$D......--|
00000060 c0 26 28 84 f9 85 12 14 4a 4a 32 c9 49 37 48 56 |.&(.....JJ2.I7HV|
00000070 00 bd b6 55 4a cc 37 98 30 dc 8f b2 66 19 a4 d8 |...UJ.7.0...f...|
00000080 94 b8 94 3d bf 8d 3c b1 37 c7 6e b7 0c 09 d1 ba |...=..<.7.n.....|
00000090 60 9b 7a 22 d9 68 9c 2b 38 58 84 55 31 85 5d 1a |`.z".h.+8X.U1.].|
@realchrisolin
realchrisolin / newcase
Created February 13, 2020 20:47
utility script to automatically create new directories associated with support cases (to manage log files from multiple customers/cases)
########################################################
# vim:ft=sh:smd:ar:si:et:bg=dark:ts=4:sw=4
# file: newcase
# author: Chris Olin - http://chrisolin.com
# purpose: automatically create new case directories
# created date: 12-12-2012
# license:
########################################################
#post-run stuff