⚙️ POWERSHELL RUNE DIFFICULTY: Archmage Structural

The Bridge of Execution Contexts

Decouple an abstraction from its implementation so that the two can vary independently.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Bridge
ARCANUM SCHOOL: Enchantment // Sysadmin Telepathy
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// POWERSHELL PATTERN //
class IExecutionPlatform {
    [void] RunCommand([string]$cmd) { throw "Not Implemented" }
}

class LocalPlatform : IExecutionPlatform {
    [void] RunCommand([string]$cmd) {
        Write-Host "Executing locally: $cmd" -ForegroundColor Green
    }
}

class RemotePSSessionPlatform : IExecutionPlatform {
    [void] RunCommand([string]$cmd) {
        Write-Host "Invoking remotely via WinRM: $cmd" -ForegroundColor Cyan
    }
}

class SysadminTask {
    [IExecutionPlatform]$_platform

    SysadminTask([IExecutionPlatform]$platform) {
        $this._platform = $platform
    }

    [void] Execute() { throw "Not Implemented" }
}

class ServiceRestartTask : SysadminTask {
    ServiceRestartTask([IExecutionPlatform]$platform) : base($platform) {}

    [void] Execute() {
        Write-Host "Initiating Service Restart Task..."
        $this._platform.RunCommand("Restart-Service spooler")
    }
}

# Bridging logic and execution
$localTask = [ServiceRestartTask]::new([LocalPlatform]::new())
$localTask.Execute()

$remoteTask = [ServiceRestartTask]::new([RemotePSSessionPlatform]::new())
$remoteTask.Execute()

The Bridge constructs a telepathic link between the logical intent of a sysadmin (the task) and the physical plane of its execution (local vs. remote). It untangles the monolithic hierarchy.

Runic Tags: #powershell #sysadmin #structural #bridge #remote-execution