Skip to content

Instantly share code, notes, and snippets.

@Joseph413168
Created December 14, 2024 14:26
Show Gist options
  • Select an option

  • Save Joseph413168/5ea4787ab2210b8a8c239d808ac77669 to your computer and use it in GitHub Desktop.

Select an option

Save Joseph413168/5ea4787ab2210b8a8c239d808ac77669 to your computer and use it in GitHub Desktop.
@echo on
setlocal enabledelayedexpansion
:: Create a directory to store output files
set OUTPUT_DIR=%~dp0System_Information
mkdir "%OUTPUT_DIR%"
:: Create subdirectories for categorized outputs
mkdir "%OUTPUT_DIR%\System"
mkdir "%OUTPUT_DIR%\Network"
mkdir "%OUTPUT_DIR%\Files"
mkdir "%OUTPUT_DIR%\Processes"
mkdir "%OUTPUT_DIR%\Users"
mkdir "%OUTPUT_DIR%\Updates"
mkdir "%OUTPUT_DIR%\Logs"
mkdir "%OUTPUT_DIR%\Firewall"
mkdir "%OUTPUT_DIR%\Environment"
mkdir "%OUTPUT_DIR%\Disk"
:: Gather network information using PowerShell
echo Gathering network information...
powershell -Command "Get-NetIPAddress | Out-File -FilePath '%OUTPUT_DIR%\Network\NetworkConfig.txt'"
netstat -ano > "%OUTPUT_DIR%\Network\ActiveConnections.txt"
arp -a > "%OUTPUT_DIR%\Network\ARP_Cache.txt"
netsh wlan show profiles > "%OUTPUT_DIR%\Network\WiFiProfiles.txt"
(for /f "tokens=*" %%i in ('netsh wlan show profiles') do netsh wlan show profile name="%%i" key=clear) > "%OUTPUT_DIR%\Network\WiFiPasswords.txt"
netsh wlan show all > "%OUTPUT_DIR%\Network\WiFiReport.txt"
netsh wlan show wlan report > "%OUTPUT_DIR%\Network\WlanReport.html"
:: Gather file and directory details
echo Gathering file and directory details...
:: Use the "dir" command with error handling to get all files, suppressing access errors
dir /s /a C:\ 2> "%OUTPUT_DIR%\Files\AllFilesOnC_Errors.txt" > "%OUTPUT_DIR%\Files\AllFilesOnC.txt"
fsutil fsinfo drives > "%OUTPUT_DIR%\Files\AvailableDrives.txt"
vol > "%OUTPUT_DIR%\Files\DriveVolumeDetails.txt"
:: Gather running processes and services using PowerShell
echo Gathering process and service information...
powershell -Command "Get-Process | Out-File -FilePath '%OUTPUT_DIR%\Processes\RunningProcesses.txt'"
powershell -Command "Get-Service | Out-File -FilePath '%OUTPUT_DIR%\Processes\Services.txt'"
:: Gather user and privilege details
echo Gathering user and privilege information...
whoami /all > "%OUTPUT_DIR%\Users\UserPrivileges.txt"
wmic useraccount get name,sid > "%OUTPUT_DIR%\Users\UserAccounts.txt" :: Simplified query to avoid issues
:: Gather Windows update details using PowerShell
echo Gathering Windows update details...
powershell -Command "Get-WindowsUpdateLog; Move-Item -Path $HOME\Desktop\WindowsUpdate.log -Destination '%OUTPUT_DIR%\Updates\UpdateLog.txt' -Force"
:: Gather event logs using PowerShell
echo Gathering system logs...
powershell -Command "Get-WinEvent -LogName System -MaxEvents 100 | Out-File -FilePath '%OUTPUT_DIR%\Logs\SystemLogs.txt'"
:: Gather firewall settings
echo Gathering firewall settings...
netsh advfirewall show allprofiles > "%OUTPUT_DIR%\Firewall\FirewallSettings.txt"
:: Gather environment variables
echo Gathering environment variables...
set > "%OUTPUT_DIR%\Environment\EnvironmentVariables.txt"
:: Check disk health using PowerShell
echo Gathering disk health information...
powershell -Command "Get-PhysicalDisk | Select-Object -Property FriendlyName,OperationalStatus | Out-File -FilePath '%OUTPUT_DIR%\Disk\DiskHealth.txt'"
:: Gather battery report
echo Generating battery report...
powercfg /batteryreport /output "%OUTPUT_DIR%\System\BatteryReport.html"
:: Gather energy report
echo Generating energy report...
powercfg /energy /output "%OUTPUT_DIR%\System\EnergyReport.html"
:: Gather system information
echo Gathering system information...
wmic computersystem get model,name,manufacturer,systemtype > "%OUTPUT_DIR%\System\ComputerDetails.txt"
wmic cpu get name,caption > "%OUTPUT_DIR%\System\CPU_Details.txt"
wmic memorychip get capacity,manufacturer,speed > "%OUTPUT_DIR%\System\Memory_Details.txt"
wmic diskdrive get model,size,serialnumber > "%OUTPUT_DIR%\System\Disk_Details.txt"
msinfo32 /report "%OUTPUT_DIR%\System\MSInfo32_Report.txt"
:: Notify completion
echo All information has been gathered and saved in "%OUTPUT_DIR%".
explorer "%OUTPUT_DIR%"
endlocal
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment