# proxb/poshpaig architecture

> Architecture diagram of the GitHub repository proxb/poshpaig, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/proxb/poshpaig
- Repository: https://github.com/proxb/poshpaig

## Overview

##### Project type and purpose
- PoshPAIG is a Windows-based administrative tool written entirely in PowerShell.
- It provides a graphical user interface (UI) for auditing and pushing WSUS updates to local and remote machines.

##### File structure
- Top-level scripts:
- Start-PoshPAIG.ps1: Launches the UI
- Options.ps1: Contains global configuration and settings
- Exempt.txt, PSexec.txt: Sample or external-tool references
- /Scripts folder: Core operational modules
- Get-ComputerRebootState.ps1, Get-PendingUpdates.ps1, Get-UpdateLog.ps1, Install-Patches.ps1
- Each script encapsulates a discrete function (audit, report, install)
- /HelpFiles: Inline help and documentation modules (About.ps1, HelpOverview.ps1)
- /GitHub_Images & /Images: UI screenshots and assets
- README.md: Project overview and sample UI screenshot

##### README for additional insights
- Confirms the objective: GUI front-end for WSUS tasks
- Implies use of Windows Forms or WPF for UI (PowerShell-based)
- No external database; uses WSUS API and WinRM/CIM sessions for remote operations

a. Main components
- User Interface (UI) – a PowerShell host window with forms and controls
- Core Script Engine – the PowerShell runtime loading modules and functions
- Operational Modules – the .ps1 files in /Scripts that perform WSUS queries and patch deployments
- Configuration Store – Options.ps1 and Exempt.txt that define preferences and exclusions
- Remote Management Layer – WinRM/CIM sessions used to connect to target endpoints
- WSUS Server – the upstream update source and API endpoint
- Target Systems – local or remote Windows machines receiving queries and patch instructions

b. Relationships and interactions
1. UI invokes Start-PoshPAIG.ps1
2. Core Script Engine imports configuration (Options.ps1)
3. User actions (buttons/menus) call specific scripts in /Scripts
4. Each script uses WinRM/CIM to gather data from or send commands to target systems
5. For patch metadata or downloads, scripts call the WSUS Server API over HTTP/HTTPS
6. Results and logs flow back into the UI for display or written to local log files

c. Architectural patterns and design principles
- Modular design: each core functionality lives in its own script
- Separation of concerns: UI, configuration, and business logic are physically separated
- Extensibility: new scripts can be dropped into /Scripts and automatically invoked
- Thin-client orchestration: no database; relies on existing WSUS infrastructure and WinRM

d. Key technologies and frameworks
- PowerShell v5+ (Runspaces for UI)
- .NET Windows Forms or WPF libraries (loaded via Add-Type)
- WSUS API (Microsoft.UpdateServices.Administration namespace)
- WinRM / CIM sessions for remote calls
- File-based configuration

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "UI & Configuration" 
        UI["User Interface\n(Start-PoshPAIG.ps1)"]:::uiConfig
        Options["Options.ps1"]:::uiConfig
        Exempt["Exempt.txt"]:::uiConfig
    end

    subgraph "Core Script Engine" 
        Engine["PowerShell Host & Runspaces"]:::scriptEngine
    end

    subgraph "Operational Modules" 
        M1["Get-ComputerRebootState.ps1"]:::modules
        M2["Get-PendingUpdates.ps1"]:::modules
        M3["Get-UpdateLog.ps1"]:::modules
        M4["Install-Patches.ps1"]:::modules
    end

    subgraph "Help & Documentation" 
        About["About.ps1"]:::uiConfig
        HelpOverview["HelpOverview.ps1"]:::uiConfig
    end

    subgraph "Assets & References" 
        Images["Images/"]:::assets
        GitHubImages["GitHub_Images/"]:::assets
        README["README.md"]:::uiConfig
        PSexec["PSexec.txt"]:::uiConfig
    end

    WSUS["WSUS Server\nAPI Endpoint"]:::external
    Targets["Target Systems\n(WinRM/CIM)"]:::external

    %% Relationships
    UI -->|"launches"| Engine
    Options -->|load config| Engine
    Exempt -->|load exclusions| Engine
    Engine -->|"invoke"| M1
    Engine -->|"invoke"| M2
    Engine -->|"invoke"| M3
    Engine -->|"invoke"| M4
    M1 -->|"audit via WinRM"| Targets
    M2 -->|"query via WinRM"| Targets
    M3 -->|"retrieve logs via WinRM"| Targets
    M4 -->|"deploy via WinRM"| Targets
    M2 -->|"metadata requests"| WSUS
    M4 -->|"download patches"| WSUS
    Targets -->|"status & logs"| UI

    %% Click Events
    click UI "https://github.com/proxb/poshpaig/blob/master/Start-PoshPAIG.ps1"
    click Options "https://github.com/proxb/poshpaig/blob/master/Options.ps1"
    click Exempt "https://github.com/proxb/poshpaig/blob/master/Exempt.txt"
    click M1 "https://github.com/proxb/poshpaig/blob/master/Scripts/Get-ComputerRebootState.ps1"
    click M2 "https://github.com/proxb/poshpaig/blob/master/Scripts/Get-PendingUpdates.ps1"
    click M3 "https://github.com/proxb/poshpaig/blob/master/Scripts/Get-UpdateLog.ps1"
    click M4 "https://github.com/proxb/poshpaig/blob/master/Scripts/Install-Patches.ps1"
    click About "https://github.com/proxb/poshpaig/blob/master/HelpFiles/About.ps1"
    click HelpOverview "https://github.com/proxb/poshpaig/blob/master/HelpFiles/HelpOverview.ps1"
    click Images "https://github.com/proxb/poshpaig/tree/master/Images/"
    click GitHubImages "https://github.com/proxb/poshpaig/tree/master/GitHub_Images/"
    click README "https://github.com/proxb/poshpaig/blob/master/README.md"
    click PSexec "https://github.com/proxb/poshpaig/blob/master/PSexec.txt"

    %% Styles
    classDef uiConfig fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef scriptEngine fill:#90EE90,stroke:#000,stroke-width:1px
    classDef modules fill:#FFA500,stroke:#000,stroke-width:1px
    classDef external fill:#DDA0DD,stroke:#000,stroke-width:1px
    classDef assets fill:#87CEEB,stroke:#000,stroke-width:1px
```
