Skip to content

Instantly share code, notes, and snippets.

@charlesrc019
Last active November 8, 2024 02:20
Show Gist options
  • Select an option

  • Save charlesrc019/9be2cd876bc027427897098265bd9efe to your computer and use it in GitHub Desktop.

Select an option

Save charlesrc019/9be2cd876bc027427897098265bd9efe to your computer and use it in GitHub Desktop.
endpoint_generate_system_report.ps1
# Collect system data.
$System = Get-WMIObject -class Win32_ComputerSystem
$BIOS = Get-WMIObject -class Win32_BIOS
$Processor = Get-WMIObject -class Win32_Processor
$OS = Get-WMIObject -class Win32_OperatingSystem
$Processes = Get-WMIObject -class Win32_Process
# Organize data.
$Uptime = (Get-Date) - [datetime]::parseexact($OS.LastBootUpTime.split('.')[0],"yyyyMMddHHmmss",[System.Globalization.CultureInfo]::InvariantCulture)
$SystemInfo = [pscustomobject] @{
Hostname = $System.Name
Owner = $System.PrimaryOwnerName
Manufacturer = $System.Manufacturer
Model = $System.Model
SerialNumber = $BIOS.SerialNumber
ProcessorType = $Processor.Name
ProcessorCores = $Processor.NumberOfCores
Memory = ([string]( $System.TotalPhysicalMemory / (1024*1024*1024) )).split('.')[0] + " GB"
BIOSVersion = $BIOS.SMBIOSBIOSVersion
OSVersion = "Microsoft Windows " + $OS.Version
Domain = $System.Domain
LastBootTime = [datetime]::parseexact($OS.LastBootUpTime.split('.')[0],"yyyyMMddHHmmss",[System.Globalization.CultureInfo]::InvariantCulture)
Uptime = "{0:00}d {1:00}h {2:00}m {3:00}s" -f $Uptime.Days,$Uptime.Hours,$Uptime.Minutes,$Uptime.Seconds
ActiveProcesses = $Processes.Count
}
$SystemProcesses = $Processes | Select ProcessId,Name,CreationDate,CommandLine | Sort-Object CreationDate | Format-Table -Property ProcessId,Name,CreationDate,CommandLine
# Write data to file.
$InformationFile = "$env:USERPROFILE\Desktop\SystemInformation.txt"
$SystemInfo > $InformationFile
$SystemProcesses >> $InformationFile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment