___ _____   ___         _      _
  |_ _|_   _| / __| __ _ _(_)_ __| |_ ___
   | |  | |   \__ \/ _| '_| | '_ \  _(_-<
  |___| |_|   |___/\__|_| |_| .__/\__/__/
                             |_|

IT Convenience Scripts

curl it • pipe it • done

/crcfix
Solves CRC error while downloading from filewave booster servers
curl -fsSL https://scripts.bonnier.news/crcfix | bash
#!/usr/bin/env bash
set -euo pipefail
echo "Running CRC booster fix script..."

# Removes all booster servers, forcing the client to connect directly to the filewave server.
echo "Removing booster servers..."
sudo defaults write /usr/local/etc/fwcld.plist booster1 no.booster.set
sudo defaults write /usr/local/etc/fwcld.plist booster2 no.booster.set
sudo defaults write /usr/local/etc/fwcld.plist booster3 no.booster.set
sudo defaults write /usr/local/etc/fwcld.plist booster4 no.booster.set
sudo defaults write /usr/local/etc/fwcld.plist booster5 no.booster.set
sudo chmod 644 /usr/local/etc/fwcld.plist

echo "Booster servers removed succesfully, restarting filewave client..."
sudo fwcontrol client restart
echo "Waiting for 30 seconds to allow the client to restart..."
sleep 30
sudo touch /etc/resolv.conf # Touching resolv.conf triggers a network change, and puts back the boosters we removed.
echo "Done!"
/hwinfo
Prints chip name, battery health, RAM, serial number and macOS version
curl -fsSL https://scripts.bonnier.news/hwinfo | bash
#!/usr/bin/env bash
set -euo pipefail

echo "Device info:"
hw_profiler="$(system_profiler SPHardwareDataType 2>/dev/null)"

chip="$(printf '%s\n' "$hw_profiler" | awk -F': ' '/Chip:/{print $2; exit}')"
if [[ -z "$chip" ]]; then
	chip="$(printf '%s\n' "$hw_profiler" | awk -F': ' '/Processor Name:/{print $2; exit}')"
fi
if [[ -z "$chip" ]]; then
	chip="Unknown"
fi
echo "$chip"

ioreg -l | grep -E '"DesignCapacity" =|"AppleRawMaxCapacity"' | grep -o '[0-9]*' | tr '\n' ',' | awk -F"," '{print (int(($2/$1)*1000 + 0.5)/10 "% battery health")}'

mem="$(printf '%s\n' "$hw_profiler" | awk -F': ' '/Memory:/{print $2; exit}')"
if [[ -z "$mem" ]]; then
	mem_bytes="$(sysctl -n hw.memsize 2>/dev/null || true)"
	if [[ -n "$mem_bytes" ]]; then
		mem="$(awk -v b="$mem_bytes" 'BEGIN { if (b>0) printf "%.0f GB", b/1073741824 }')"
	fi
fi
if [[ -z "$mem" ]]; then
	mem="Unknown"
fi
echo "$mem"

serial="$(printf '%s\n' "$hw_profiler" | awk -F': ' '/Serial Number \(system\):/{print $2; exit}')"
if [[ -z "$serial" ]]; then
	serial="Unknown"
fi
echo "$serial"

echo "$(sw_vers -productName) $(sw_vers -productVersion)"
/oobe-visualizer
Generates an interactive HTML diagram of the local Windows OOBE setup flow
irm https://scripts.bonnier.news/oobe-visualizer | iex
Write-Host "Installing required PSWriteHTML module..." -ForegroundColor Cyan
Install-Module -Name PSWriteHTML -Force -AcceptLicense -Scope CurrentUser -ErrorAction SilentlyContinue

Write-Host "Generating OOBE flow diagram..." -ForegroundColor Cyan

# Note: Changed $PSScriptRoot to $env:TEMP so it works when executed from memory
New-HTML -TitleText 'OOBE' -Online -FilePath "$env:TEMP\OOBE.html" {
    New-HTMLPanel {
        New-HTMLDiagram -Height '2000px' -Width '3000px' {
            New-DiagramOptionsInteraction -Hover $true
            New-DiagramOptionsPhysics -Enabled $true
            New-DiagramOptionsLayout -RandomSeed 0
            New-DiagramOptionsLinks -ArrowsToEnabled $true -Color BlueViolet -ArrowsToType arrow -ArrowsFromEnabled $false
            New-DiagramOptionsNodes -BorderWidth 1 -FontColor Black -Size 16 -FontMulti true
            
            $file = "C:\Windows\SystemApps\Microsoft.Windows.CloudExperienceHost_cw5n1h2txyewy\data\prod\navigation.json"
            if (-not (Test-Path $file)) {
                Write-Warning "Could not find the OOBE navigation.json file on this system."
                return
            }

            $nav = Get-Content $file | ConvertFrom-Json -Depth 999 -AsHashtable
            $nav.FRXINCLUSIVE.Keys | Where-Object { $nav.FRXINCLUSIVE.$_.count -gt 1} | ForEach-Object {
                Write-Host "Mapping Node: $_"
                New-DiagramNode -Label "$_" -IconSolid desktop -Title "$_"
                if ($null -ne $nav.FRXINCLUSIVE.$_.successID) {
                    New-DiagramLink -From "$_" -To "$($nav.FRXINCLUSIVE.$_.successID)"
                }
            }
        }
    }
} -ShowHTML
/sccm-cycles
Sync SCCM Client Configuration Cycles
irm https://scripts.bonnier.news/sccm-cycles | iex
# Source - https://stackoverflow.com/a/70869951
# Posted by Suncat2000, Retrieved 2026-04-01, License - CC BY-SA 4.0
# Modified for in-memory execution, GPUpdate, and UI improvements

# 1. Smart Self-Elevation (Handles both local .ps1 files and in-memory execution)
$isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)

if (-Not $isAdmin) {
    Write-Warning "Administrator privileges required. Attempting to elevate..."
    
    if ($PSCommandPath) {
        # Executed from a local file (Debugging)
        Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList "-NoProfile -File `"$PSCommandPath`""
    } else {
        # Executed in-memory via 'irm | iex'
        $ElevatedCommand = "-NoProfile -Command `"irm http://192.168.250.1:7676/sccm-cycles | iex`""
        Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $ElevatedCommand
    }
    Exit
}

# 2. Define the SCCM Cycles with descriptions
$sccmCycles = @(
    [pscustomobject]@{ ID = "{00000000-0000-0000-0000-000000000001}"; Name = "Hardware Inventory Cycle" }
    [pscustomobject]@{ ID = "{00000000-0000-0000-0000-000000000002}"; Name = "Software Inventory & Collect Files" }
    [pscustomobject]@{ ID = "{00000000-0000-0000-0000-000000000003}"; Name = "Discovery Data Collection (Heartbeat)" }
    [pscustomobject]@{ ID = "{00000000-0000-0000-0000-000000000010}"; Name = "Software Metering Usage Report Cycle" }
    [pscustomobject]@{ ID = "{00000000-0000-0000-0000-000000000021}"; Name = "Request Machine Assignments" }
    [pscustomobject]@{ ID = "{00000000-0000-0000-0000-000000000022}"; Name = "Evaluate Machine Policies" }
    [pscustomobject]@{ ID = "{00000000-0000-0000-0000-000000000031}"; Name = "Software Metering Generate Usage Report" }
    [pscustomobject]@{ ID = "{00000000-0000-0000-0000-000000000040}"; Name = "Machine Policy Agent Cleanup" }
    [pscustomobject]@{ ID = "{00000000-0000-0000-0000-000000000042}"; Name = "Policy Agent Validate Machine Policy" }
    [pscustomobject]@{ ID = "{00000000-0000-0000-0000-000000000105}"; Name = "Get IDMIF Files" }
    [pscustomobject]@{ ID = "{00000000-0000-0000-0000-000000000108}"; Name = "Software Updates Evaluation Cycle" }
    [pscustomobject]@{ ID = "{00000000-0000-0000-0000-000000000111}"; Name = "Windows PE Peer Cache Cleanup" }
    [pscustomobject]@{ ID = "{00000000-0000-0000-0000-000000000113}"; Name = "Software Updates Scan Cycle" }
    [pscustomobject]@{ ID = "{00000000-0000-0000-0000-000000000114}"; Name = "Windows Installer Source List Update" }
    [pscustomobject]@{ ID = "{00000000-0000-0000-0000-000000000115}"; Name = "State Message Manager Delivery" }
    [pscustomobject]@{ ID = "{00000000-0000-0000-0000-000000000121}"; Name = "Application Manager Machine Policy Action" }
    [pscustomobject]@{ ID = "{00000000-0000-0000-0000-000000000131}"; Name = "Power Management Client Activity" }
)

Write-Host ""
Write-Host "===========================================================" -ForegroundColor Cyan
Write-Host " Initiating System Sync & Configuration Cycles" -ForegroundColor White
Write-Host "===========================================================" -ForegroundColor Cyan
Write-Host ""

# 3. Group Policy Update
Write-Host " > Triggering " -NoNewline
Write-Host "$("Group Policy Update (gpupdate)".PadRight(45))" -ForegroundColor Yellow -NoNewline

try {
    # Pipe output to $null to keep the console clean while it waits
    $null = gpupdate.exe /force /Wait:-1 2>&1
    if ($LASTEXITCODE -eq 0) {
        Write-Host "[ OK ]" -ForegroundColor Green
    } else {
        Write-Host "[WARN]" -ForegroundColor DarkYellow
    }
} catch {
    Write-Host "[FAIL]" -ForegroundColor Red
}

# 4. SCCM Cycles
foreach ($cycle in $sccmCycles) {
    Write-Host " > Triggering " -NoNewline
    Write-Host "$($cycle.Name.PadRight(45))" -ForegroundColor Yellow -NoNewline
    
    try {
        $null = Invoke-WMIMethod -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule -ArgumentList $cycle.ID -ErrorAction Stop
        Write-Host "[ OK ]" -ForegroundColor Green
    } catch {
        Write-Host "[FAIL]" -ForegroundColor Red
    }
}

Write-Host ""
Write-Host "===========================================================" -ForegroundColor Cyan
Write-Host " Sync completed!" -ForegroundColor Green
Write-Host "===========================================================" -ForegroundColor Cyan
Write-Host ""