Whilst working on my chat bot I got to thinking about how it would be great if an end user could run a simple script to gather basic information about their computer and came up with the below. It’s a script that captures the computers name, model, serial number, RAM, 25 recent errors from the Application and System Logs and finally it notes any application hangs before dumping all the information into a text file (to easily be given to tech support). I was also considering recording IP address, MAC address and possibly recently installed Windows Updates (all possible via PowerShell).

#Powershell script to gather computer basics

$text = “What’s wrong with my PC?”

#This is where the file is saved

$reportname = “C:\Temp\report.txt”

 

$text | out-file $reportname

 

#This outputs the basic computer information

Get-WmiObject -Class Win32_ComputerSystem | out-file $reportname -append

 

#This outputs the last 25 system log errors

$syslogoutput = “System Log Errors”

$syslogoutput | out-file $reportname -append

Get-EventLog -LogName System -EntryType Error -Newest 25 | out-file $reportname -append

 

#This outputs the last 25 application log errors

$applogoutput = “App Log Errors”

$applogoutput | out-file $reportname -append

Get-EventLog -LogName Application -EntryType Error -Newest 25 | out-file $reportname -append

 

#This ouputs any application hang events

$apphangoutput = “Application Hang Events”

$apphangoutput | out-file $reportname -append

Get-WmiObject Win32_ReliabilityRecords -Filter “SourceName=’Application Hang’” | out-file $reportname -append

Welcome to GeekTechStuff

my home away from home and where I will be sharing my adventures in the world of technology and all things geek.

The technology subjects have varied over the years from Python code to handle ciphers and Pig Latin, to IoT sensors in Azure and Python handling Bluetooth, to Ansible and Terraform and material around DevOps.

Let’s connect