Public/(NoAnsi)AeroFetch.ps1

function AeroFetch {
    <#
        .SYNOPSIS
            AeroFetch: System Information Command-Line Utility for Windows Operating Systems
 
        .DESCRIPTION
            ;
         
        .PARAMETER ThemeName
            Specifies the name of the Ascii Art Theme used.
 
        .PARAMETER ThemeAssetName
            Specifies the specific Ascii Art Asset to pull from the specified Theme. If a particular asset is not specified, then the asset labeled 'Default' will be pulled.
    #>


    [CmdletBinding()]
    param(
        [Parameter()]
        [string]$ThemeName = 'WindowsStylized',
        [Parameter()]
        $ThemeAssetName = 'WindowsPopClassic'
    )

    #- BEGINNING OF SCRIPT

    #region Baseline Variables

    $ModuleRoot = Split-Path $PSScriptRoot -Parent


#region Gather and Format System Information

$CIMData = @{
    ComputerSystem  = Get-CimInstance Win32_ComputerSystem
    OperatingSystem = Get-CimInstance Win32_OperatingSystem
    Motherboard     = Get-CimInstance Win32_BaseBoard
    VideoController = Get-CimInstance Win32_VideoController
    CPU             = Get-CimInstance CIM_Processor
    GPU             = Get-CimInstance Win32_DisplayConfiguration
    LogicalDisk     = Get-CimInstance Win32_LogicalDisk
    Network         = Get-NetConnectionProfile
    Battery         = Get-CimInstance Win32_Battery
}

$UserInfo = "$Env:USERNAME\$Env:USERDOMAIN - $($CIMData.ComputerSystem.Workgroup) "

$OSInfo = "$($CIMData.OperatingSystem.Caption) ($($CIMData.OperatingSystem.OSArchitecture))"

$Uptime = (([DateTime]$CIMData.OperatingSystem.LocalDateTime) - ([DateTime]$CIMData.OperatingSystem.LastBootUpTime));
$UptimeFormat = $Uptime.Days.ToString() + ' Days ' + $Uptime.Hours.ToString() + ' Hours ' + $Uptime.Minutes.ToString() + ' Minutes ' + $Uptime.Seconds.ToString() + ' Seconds '

$UptimeInfo = $UptimeFormat

# Motherboard Information Processing
$MotherboardInfo = "$($CIMData.Motherboard.Manufacturer) $($CIMData.Motherboard.Product)"


# Ketnel Information Processing
$KernelInfo = (Get-ItemProperty -Path "${env:SystemRoot}\System32\ntoskrnl.exe").VersionInfo.FileVersion


# (Power)Shell Information Processing
$ShellInfo = "Microsoft PowerShell Version $($PSVersionTable.PSVersion.ToString()) | $($Host.Name)"


# Video Controller Information Processing
$ResolutionInfo = $CIMData.VideoController.CurrentHorizontalResolution.ToString() + " x " + $CIMData.VideoController.CurrentVerticalResolution.ToString() + " (" + $CIMData.VideoController.CurrentRefreshRate.ToString() + "Hz)"

# Processes Information Processing
$Processes = Get-Process
$ProcInfo = $Processes.Count

# CPU and GPU Information Processing
$CPUInfo = $CIMData.CPU.Name
$GPUInfo = $CIMData.GPU.DeviceName

# System Memory (RAM) Information Processing
$AvailableRAM = ([math]::Truncate($Win32Info.FreePhysicalMemory / 1KB))
$TotalRAM = ([math]::Truncate((Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory / 1MB))
$UsedRAM = $TotalRAM - $AvailableRAM
$AvailableRAMPercent = ($AvailableRAM / $TotalRAM) * 100
$AvailableRAMPercent = "{0:N0}" -f $AvailableRAMPercent
$UsedRamPercent = ($UsedRam / $TotalRAM) * 100
$UsedRamPercent = "{0:N0}" -f $UsedRamPercent
$RAMInfo = $UsedRAM.ToString() + "MB / " + $TotalRAM.ToString() + " MB " + "(" + $UsedRamPercent.ToString() + "%" + ")"


# Logical Disk Information Processing
$Disk = Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DeviceID='$env:SystemDrive'" -ErrorAction Stop | Select-Object Size, FreeSpace
$DiskTotal = [math]::Round($Disk.Size / 1GB, 2)
$DiskFree = [math]::Round($Disk.FreeSpace / 1GB, 2)
$DiskUsed = [math]::Round($DiskTotal - $DiskFree, 2)
$DiskPercent = [math]::Round(($DiskUsed / $DiskTotal) * 100)
$DiskInfo = "$env:SystemDrive ${DiskUsed}GB / ${DiskTotal}GB (${DiskPercent}%)"


<#$FormattedDisks = New-Object System.Collections.Generic.List[System.Object];
 
    $NumDisks = $LogicalDisk.Count;
 
    if ($NumDisks) {
        for ($i=0; $i -lt ($NumDisks); $i++) {
            $DiskID = $LogicalDisk[$i].DeviceId;
 
            $DiskSize = $LogicalDisk[$i].Size;
 
            if ($DiskSize -gt 0) {
                $FreeDiskSize = $LogicalDisk[$i].FreeSpace
                $FreeDiskSizeGB = $FreeDiskSize / 1073741824;
                $FreeDiskSizeGB = "{0:N0}" -f $FreeDiskSizeGB;
 
                $DiskSizeGB = $DiskSize / 1073741824;
                $DiskSizeGB = "{0:N0}" -f $DiskSizeGB;
 
                if ($DiskSizeGB -gt 0 -And $FreeDiskSizeGB -gt 0) {
                    $FreeDiskPercent = ($FreeDiskSizeGB / $DiskSizeGB) * 100;
                    $FreeDiskPercent = "{0:N0}" -f $FreeDiskPercent;
 
                    $UsedDiskSizeGB = $DiskSizeGB - $FreeDiskSizeGB;
                    $UsedDiskPercent = ($UsedDiskSizeGB / $DiskSizeGB) * 100;
                    $UsedDiskPercent = "{0:N0}" -f $UsedDiskPercent;
                }
                else {
                    $FreeDiskPercent = 0;
                    $UsedDiskSizeGB = 0;
                    $UsedDiskPercent = 0;
                }
            }
            else {
                $DiskSizeGB = 0;
                $FreeDiskSizeGB = 0;
                $FreeDiskPercent = 0;
                $UsedDiskSizeGB = 0;
                $UsedDiskPercent = 100;
            }
/
            $FormattedDisk = "Disk " + $DiskID.ToString() + " " +
                $UsedDiskSizeGB.ToString() + "GB" + " / " + $DiskSizeGB.ToString() + "GB " +
                "(" + $UsedDiskPercent.ToString() + "%" + ")";
            $FormattedDisks.Add($FormattedDisk);
        }
    }
    else {
        $DiskID = $LogicalDisk.DeviceId;
 
        $FreeDiskSize = $LogicalDisk.FreeSpace
        $FreeDiskSizeGB = $FreeDiskSize / 1073741824;
        $FreeDiskSizeGB = "{0:N0}" -f $FreeDiskSizeGB;
 
        $DiskSize = $LogicalDisk.Size;
        $DiskSizeGB = $DiskSize / 1073741824;
        $DiskSizeGB = "{0:N0}" -f $DiskSizeGB;
 
        if ($DiskSize -gt 0 -And $FreeDiskSize -gt 0 ) {
            $FreeDiskPercent = ($FreeDiskSizeGB / $DiskSizeGB) * 100;
            $FreeDiskPercent = "{0:N0}" -f $FreeDiskPercent;
 
            $UsedDiskSizeGB = $DiskSizeGB - $FreeDiskSizeGB;
            $UsedDiskPercent = ($UsedDiskSizeGB / $DiskSizeGB) * 100;
            $UsedDiskPercent = "{0:N0}" -f $UsedDiskPercent;
 
            $FormattedDisk = "Disk " + $DiskID.ToString() + " " +
                $UsedDiskSizeGB.ToString() + "GB" + " / " + $DiskSizeGB.ToString() + "GB " +
                "(" + $UsedDiskPercent.ToString() + "%" + ")";
            $FormattedDisks.Add($FormattedDisk);
        }
        else {
            $FormattedDisk = "Disk " + $DiskID.ToString() + " Empty";
            $FormattedDisks.Add($FormattedDisk);
        }
    }
 
$DiskInfo = $FormattedDisks#>


# Network Information Processing
if ($CIMData.Network.Name) {
    $NetworkInfo = "$($CIMData.Network.Name) ($($CIMData.Network.NetworkCategory) $($CIMData.Network.InterfaceAlias) Network)"
} else {
    $NetworkInfo = 'No Network Connection'
}
# Battery Information Processing
$BatteryCharge = "$($CIMData.Battery.EstimatedChargeRemaining)% Remaining"
$BatteryStatus = Switch ($CIMData.Battery.BatteryStatus) {
    1 { "Discharging" }
    2 { "AC Power" }
    3 { "Fully Charged" }
    4 { "Low" }
    5 { "Critical" }
    6 { "Charging" }
    7 { "Charging and High" }
    8 { "Charging and Low" }
    9 { "Charging and Critical" }
    10 { "Undefined" }
    11 { "Partially Charged" }
    default { "Unknown" }
}

if ($CIMData.Battery) {
    $BatteryInfo = "$BatteryCharge [Status: $BatteryStatus]"
} else {
    $BatteryInfo = "No Battery Detected"
}


# ColorBar Processing

function Get-ColorBar {
    <#
        .SYNOPSIS
            Displays a ColorBar on-screen.
             
        .DESCRIPTION
            Displays a 16-bit ColorBar on-screen representing all 16 ConsoleColor options.
 
        .NOTES
            * CHANGELOG *
            [+] UPDATE_01
                    Date: 03-12-2025
                    Title: Initial Commit
                    Message: Initial Commit. Function displays ANSI Escape Sequence Colors representing all 16 ConsoleColor options (White/Black plus Normal and Dark variety of each of the 7 remaining colors)
 
            [+] UPDATE_xx
                    Date:
                    Title:
                    Message:
                     
             
            -------------------------------------------------------------------------------------------------------------------------
            #########################################################################################################################
            -------------------------------------------------------------------------------------------------------------------------
             
            * PLANNED UPDATES/FIXES *
                UPDATE_??-[ ]
                    Date: TBA
                    Title: Ansi Escape Configuration
                    Message:
                    Add Parameters to configure the ANSI Escape Sequence Color Values manually.
                UPDATE_??-[ ]
                    Date: TBA
                    Title: RealConsoleColor Mode
                    Message
                    Add Paramater to switch between 'RealConsoleColor' and 'AnsiEscapeSequence' display mode.
    #>


    param(
        [Parameter()]
        [ValidateSet('Both','Top','Bottom')]
        [string]$DisplayRow = 'Both'
    )

    $Esc = [char]27
    $Reset = "$Esc[0m"


    $ConsoleColorRow = "$Esc[38;5;255m███$Reset$Esc[38;5;237m███$Reset$Esc[38;5;88m███$Reset$Esc[38;5;41m███$Reset$Esc[38;5;33m███$Reset$Esc[38;5;135m███$Reset$Esc[38;5;13m███$Reset$Esc[38;5;122m███$Reset" 
    $ConsoleColorDarkRow = "$Esc[38;5;232m███$Reset$Esc[38;5;248m███$Reset$Esc[38;5;196m███$Reset$Esc[38;5;22m███$Reset$Esc[38;5;17m███$Reset$Esc[38;5;91m███$Reset$Esc[38;5;11m███$Reset$Esc[38;5;75m███$Reset"
    
    if ($DisplayRow -eq 'Both') {
        return @($ConsoleColorRow, $ConsoleColorDarkRow)
    } elseif ($DisplayRow -eq 'Top') {
        return $ConsoleColorRow
    } elseif ($DisplayRow -eq 'Bottom') {
        return $ConsoleColorDarkRow    
    }

    #region Developer Notes
    <#
 
    * Display Character:
    * Unicode Block Character - FULL BLOCK (0x2588) x3
 
     
    * Display Order:
    * TopRow: (1)White, (2)Gray, (3)Red, (4)Green, (5)Blue, (6)Magenta, (7)Yellow, (8)Cyan
    * BtmRow: (1)Black, (2)DarkGray, (3)DarkRed, (4)DarkGreen, (5)DarkBlue, (6)DarkMagenta, (7)DarkYellow, (8)DarkCyan
     
    #>

    #endregion
}



$ColorBarTop = Get-ColorBar -DisplayRow Top
$ColorBarBottom = Get-ColorBar -DisplayRow Bottom 


#endregion


#region Organize Data and Format for Display

$SystemInformation = [PSCustomObject]@{
    
    PSTypeName = 'AeroFetch.Win32SystemInfo.DataCollection'

    CurrentUser = $UserInfo

    OperatingSystem = $OSInfo

    Kernel = $KernelInfo

    SystemUptime = $UptimeInfo

    Shell = $ShellInfo

    Motherboard = $MotherboardInfo

    Display = $ResolutionInfo

    Processes = $ProcInfo

    CPU = $CPUInfo

    GPU = $GPUInfo

    Memory = $RAMInfo

    Drive = $DiskInfo

    Network = $NetworkInfo

    Battery = $BatteryInfo

}


[array]$SysInfo =
"`e[38;5;80m$($SystemInformation.CurrentUser)`e[0m",
"`e[38;5;198mOS:`e[0m $($SystemInformation.OperatingSystem)",
"`e[38;5;198mKernel:`e[0m $($SystemInformation.Kernel)",
"`e[38;5;198mSystem Uptime:`e[0m $($SystemInformation.SystemUptime)",
"`e[38;5;198mMotherboard:`e[0m $($SystemInformation.Motherboard)",
"`e[38;5;198mShell:`e[0m $($SystemInformation.Shell)",
"`e[38;5;198mWindow Manager:`e[0m explorer.exe",
"`e[38;5;198mDisplay:`e[0m $($SystemInformation.Display)",
"`e[38;5;198mCPU:`e[0m $($SystemInformation.CPU)",
"`e[38;5;198mGPU:`e[0m $($SystemInformation.GPU)",
"`e[38;5;198mProcesses:`e[0m $($SystemInformation.Processes)",
"`e[38;5;198mMemory:`e[0m $($SystemInformation.Memory)",
"`e[38;5;198mDrive:`e[0m $($SystemInformation.Drive)",
"`e[38;5;198mNetwork:`e[0m $($SystemInformation.Network)",
"`e[38;5;198mBattery:`e[0m $($SystemInformation.Battery)";

#endregion

#region Display AeroFetch Splash Screen

# Import-AeroFetchTheme -Name msWinModern -Logo ElevenClassic

$ThemePath = "$ModuleRoot\Data\Themes\$ThemeName\$ThemeName" + ".psd1"

$Theme = Import-PowerShellDataFile $ThemePath 

$Theme."$ThemeAssetName" = Invoke-Expression '$Theme.$ThemeAssetName'

Clear-Host 

$WindowHeight = [Console]::WindowHeight
$WindowHeightHalf = [math]::Round($WindowHeight/4,0)

$NewLine = "`n" * $WindowHeightHalf
Write-Host $NewLine

    for ($i = 0; $i -lt [Math]::Max($Theme."$ThemeAssetName".Count, $SysInfo.Count); $i++) {
        $output1 = if ($i -lt $Theme."$ThemeAssetName".Count) { $Theme."$ThemeAssetName"[$i] } else { "" }
        $output2 = if ($i -lt $SysInfo.Count) { $SysInfo[$i] } else { "" }

        
        Write-Host (" {0,-25} {1,-25}" -f $output1, $output2)
    }
    Write-Host ""
    Write-Host ""
    Write-Host ""
    Write-Host ""
    Write-Host ""


#endregion

# - END OF SCRIPT
}