#sysinfo.ps1 #Inumerate a systems processor, serial number, modle number, and ammount of RAM. param( [switch]$write_output, [switch]$file_location, [string]$file_path ) function Show-Notification { #Shows a notification in the system notification tray. param ( [string] $ToastTitle, [string] $ToastText ) [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null $Template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText02) $RawXML = [xml] $Template.GetXML() ($RawXML.toast.visual.binding.text|Where-Object {$_.id -eq "1"}).AppendChild($RawXml.CreateTextNode($ToastTitle)) > $null ($RawXml.toast.visual.binding.text|Where-Object {$_.id -eq "2"}).AppendChild($RawXml.CreateTextNode($ToastText)) > $null $SerializedXml = New-Object Windows.Data.Xml.Dom.XmlDocument $SerializedXml.LoadXml($RawXml.OuterXml) $Toast = [Windows.UI.Notifications.ToastNotification]::new($SerializedXml) $Toast.Tag = "PowerShell" $Toast.Group = "PowerShell" $Toast.ExpirationTime = [DateTimeOffset]::Now.AddMinutes(1) $Notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Sysinfo") $Notifier.Show($Toast); } function Find-RAM { #This finds the systems total physical memory and then returns this as a value in Gigabytes. $cs = Get-CimInstance -ClassName win32_computersystem $system_memory = $cs.totalphysicalmemory $system_memory = $system_memory * 0.000000001 #Multiplies by 0.000000001 as the number give by CIM is in bytes. $system_memory = [math]::floor($system_memory) $system_memory = [String]$system_memory + " GB" return $system_memory } function Find-Computer-Info { $cs = Get-CimInstance -ClassName Win32_ComputerSystem $bios_info = Get-CimInstance -ClassName CIM_BIOSElement $cpu_info = Get-CimInstance -ClassName Win32_Processor $gpu_info = Get-CimInstance -ClassName CIM_VideoController $computer_os_info = Get-CimInstance -ClassName CIM_OperatingSystem #Init array for storing computer's data $computer_info = @("HOSTNAME:", $cs.Name, "Domain:", $cs.Domain, "OS Version:", $computer_os_info.Caption, "OS Architecture:", $computer_os_info.OSArchitecture, "Manufacture:", $cs.manufacturer, "Model Name:", $cs.model, "Serial Number:", $bios_info.SerialNumber, "CPU Name:", $cpu_info.Name, "CPU Type:", $cpu_info.Caption, "GPU Name:", $gpu_info.Name) return $computer_info } function Show-Computer-Info { # Function writes by default to stdout. If given a command line option it will write to a file. if ($write_output.IsPresent){ #If this switch is present the script will write the output to a file. Otherwise it writes to stdout. $computer_hostname = Get-CimInstance -ClassName Win32_ComputerSystem $output_filename = "SystemProfile_" + $computer_hostname.Name + ".txt" $output_path = "" if ($file_location.IsPresent){ $output_path = "$file_path\$output_filename" }else { $output_path = $env:USERPROFILE + "\Desktop\" + $output_filename } foreach($line in $cs_info){ $line | Out-File -FilePath $output_path -Encoding utf8 -Append Show-Notification("File is done writing.`nWriten to: $output_path") } }else { foreach($line in $cs_info){ Write-Output $line } } } #Windows 7 Functions function Find-Computer-Info_7 { $cs_hostname = wmic computersystem get name $cs_domain = wmic computersystem get Domain $os_name = wmic os get Caption $os_arch = wmic computersystem get SystemType $cpu_name = wmic cpu get name $cpu_type = wmic cpu get Caption $cs_serial = wmic bios get serialnumber $cs_manufacturer = wmic bios get Manufacturer $cs_modelname = wmic csproduct get name $gpu_name = wmic path win32_VideoController get name $computer_info_7 = @( "HOSTNAME:", $cs_hostname[2], "Domain:", $cs_domain[2], "OS Version:", $os_name[2], "OS Architecture:", $os_arch[2], "Manufacture:", $cs_manufacturer[2], "Model Name:", $cs_modelname[2], "Serial Number:", $cs_serial[2], "CPU Name:", $cpu_name[2], "CPU Type:", $cpu_type[2], "GPU Type:", $gpu_name[2] ) return $computer_info_7 } function Find-RAM_7 { [wmi]$cs = Get-WmiObject -Class win32_computersystem $system_memory_7 = $cs.totalphysicalmemory / 1GB -as [int] $system_memory_7 = $system_memory_7.ToString() + "GB" return $system_memory_7 } function Show-Computer-Info_7 { if ($write_output.IsPresent){ $computer_hostname = wmic computersystem get name $output_filename = "SystemProfile_" + $computer_hostname + ".txt" $output_path = "" if ($file_location.IsPresent){ $output_path = "$file_path\$output_filename" }else { $output_path = $env:USERPROFILE + "\Desktop\" + $output_filename } foreach($line in $cs_info_7){ $line | Out-File -FilePath $output_path -Encoding ASCII -Append } }else { foreach($line in $cs_info_7){ Write-Output $line } } } $os_name = wmic os get Caption if( $os_name[2] -like "Microsoft Windows 7*" ){ $cs_info_7 = Find-Computer-Info_7 $RAM_info_7 = Find-RAM_7 $cs_info_7 += ("RAM:", $RAM_info_7) Show-Computer-Info_7 } else { $cs_info = Find-Computer-Info $RAM_info = Find-RAM $cs_info += ("RAM:", $RAM_info) Show-Computer-Info }