Skip to content

Instantly share code, notes, and snippets.

@bennyistanto
Created March 7, 2024 13:31
Show Gist options
  • Save bennyistanto/de7b81532c44a4879cad3e2ee42cfebd to your computer and use it in GitHub Desktop.
Save bennyistanto/de7b81532c44a4879cad3e2ee42cfebd to your computer and use it in GitHub Desktop.
Neofetch-like Powershell script

Saving the Script as a File

  1. Open Notepad or any text editor of your choice.
  2. Copy the entire script above and paste it into your text editor.
  3. Save the file with the extension .ps1, for example, NeoFetchLike.ps1.

Executing the Script in PowerShell

  1. Open PowerShell: Press Windows + X and select "Windows PowerShell (Admin)" or just "PowerShell" depending on your version of Windows.
  2. Navigate to the Script Location: If your script is not in the current directory, use the cd command to change to the directory where your script is saved. For example, if your script is saved in C:\Scripts, you would type cd C:\Scripts and press Enter.
  3. Execute the Script: Before executing scripts, you might need to change the PowerShell execution policy. To do this, run Set-ExecutionPolicy RemoteSigned -Scope CurrentUser and agree to the prompt. Then, to run your script, type .\NeoFetchLike.ps1 and press Enter.

This detailed script should provide a neofetch-like output in PowerShell, displaying key system information. You can customize the script further by adding or removing information based on what's most relevant to you.

Screenshot 2024-03-07 202507

# Save this script as "NeoFetchLike.ps1"
# System and User Information
$User = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
$OS = Get-CimInstance -ClassName Win32_OperatingSystem
$System = Get-CimInstance -ClassName Win32_ComputerSystem
# Hardware Information
$CPU = Get-CimInstance -ClassName Win32_Processor
$GPU = Get-CimInstance -ClassName Win32_VideoController
$RAM = Get-CimInstance -ClassName Win32_PhysicalMemory | Measure-Object -Property Capacity -Sum
$Disk = Get-CimInstance -ClassName Win32_LogicalDisk | Where-Object {$_.DriveType -eq 3}
# Format and Calculation
$TotalRAMGB = [Math]::Round($RAM.Sum / 1GB, 2)
$FreeSpaceGB = [Math]::Round(($Disk | Measure-Object -Property FreeSpace -Sum).Sum / 1GB, 2)
$TotalSpaceGB = [Math]::Round(($Disk | Measure-Object -Property Size -Sum).Sum / 1GB, 2)
# Uptime Calculation
$LastBootUpTime = $OS.LastBootUpTime
$CurrentTime = Get-Date
$Uptime = $CurrentTime - $LastBootUpTime
$UptimeFormatted = "{0} days, {1} hours, {2} minutes" -f $Uptime.Days, $Uptime.Hours, $Uptime.Minutes
# Display System Information
Write-Host "User:`t$User"
Write-Host "OS:`t$($OS.Caption) $($OS.OSArchitecture), Build $($OS.BuildNumber)"
Write-Host "Host:`t$($System.Model)"
Write-Host "Kernel:`t$($OS.Version)"
Write-Host "Uptime:`t$UptimeFormatted"
Write-Host "CPU:`t$($CPU.Name)"
Write-Host "GPU:`t$($GPU.Name)"
Write-Host "RAM:`t$TotalRAMGB GB / $($System.TotalPhysicalMemory / 1GB -as [int]) GB"
Write-Host "Disk:`t$FreeSpaceGB GB Free / $TotalSpaceGB GB Total"
# Extend this script by adding more information as per your requirements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment