From fe0b84a8989702fee6b10dad1236e376aafe016a Mon Sep 17 00:00:00 2001 From: efrick Date: Tue, 27 Apr 2021 14:47:20 -0400 Subject: [PATCH 1/3] Update to Powershell to accomidate Windows 7 --- sysinfo.ps1 | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 4 deletions(-) diff --git a/sysinfo.ps1 b/sysinfo.ps1 index 5708738..8eb4926 100644 --- a/sysinfo.ps1 +++ b/sysinfo.ps1 @@ -90,7 +90,69 @@ function Show-Computer-Info { # Function writes by default to stdout. If given a } } -$cs_info = Find-Computer-Info -$RAM_info = Find-RAM -$cs_info += ("RAM:", $RAM_info) -Show-Computer-Info \ No newline at end of file +#Windows 7 Functions + +function Find-Computer-Info_7 { + $cs_hostname = wmic computersystem get name + $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], + "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] + return $system_memory_7 +} + +function Show-Computer-Info_7 { + if ($write_output.IsPresent){ + $computer_hostname = wmic + $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 +} \ No newline at end of file -- 2.39.5 From 604a290a7ff161a1322de307660f68e7406a2acc Mon Sep 17 00:00:00 2001 From: efrick Date: Tue, 27 Apr 2021 15:30:58 -0400 Subject: [PATCH 2/3] Fix RAM output --- sysinfo.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/sysinfo.ps1 b/sysinfo.ps1 index 8eb4926..59dd12f 100644 --- a/sysinfo.ps1 +++ b/sysinfo.ps1 @@ -120,6 +120,7 @@ function Find-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 } -- 2.39.5 From 3cbdfadb8a93dd3af792fc5151fc229efd827c6f Mon Sep 17 00:00:00 2001 From: efrick Date: Tue, 27 Apr 2021 15:32:07 -0400 Subject: [PATCH 3/3] Fix For issue #4 --- sysinfo.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysinfo.ps1 b/sysinfo.ps1 index 59dd12f..d5c7eef 100644 --- a/sysinfo.ps1 +++ b/sysinfo.ps1 @@ -126,7 +126,7 @@ function Find-RAM_7 { function Show-Computer-Info_7 { if ($write_output.IsPresent){ - $computer_hostname = wmic + $computer_hostname = wmic computersystem get name $output_filename = "SystemProfile_" + $computer_hostname + ".txt" $output_path = "" if ($file_location.IsPresent){ -- 2.39.5