Skip to content

Instantly share code, notes, and snippets.

@giseongeom
Last active October 6, 2015 08:51
Show Gist options
  • Save giseongeom/014c217cab14b48b8645 to your computer and use it in GitHub Desktop.
Save giseongeom/014c217cab14b48b8645 to your computer and use it in GitHub Desktop.
2015.10.06 / 김용일님이 부탁한 내용
#requires -version 2
# 1. 시스템 OS명 -- OsName:"Windows"
$OsName = Get-WmiObject Win32_OperatingSystem | Select-Object -ExpandProperty caption
# 2. 시스템 OS 상세버젼 -- OsVersion:
# Get-WmiObject Win32_OperatingSystem | Get-Member
# Get-WmiObject Win32_OperatingSystem | Format-List *
$OsVersion = Get-WmiObject Win32_OperatingSystem | Select-Object caption,OSArchitecture,CSDVersion,MUILanguages
$OsVersionValue = $OsVersion.caption + ' ' + $OsVersion.OSArchitecture + ' ' + $OsVersion.CSDVersion + ' ' + $OsVersion.MUILanguages
# 3. 시스템 호스트명 - HostName:
# Get-WmiObject Win32_OperatingSystem | Format-List *
$HostName = $env:COMPUTERNAME
# 3-1. IP 주소
# get-WmiObject Win32_NetworkAdapterConfiguration | Format-List *
$ip=get-WmiObject Win32_NetworkAdapterConfiguration | Where {$_.Ipaddress.length -gt 1}
# 4. 시스템 CPU Core 개수 -- OSProcessorCnt
# Get-WmiObject Win32_Processor | Format-List *
$OSProcessorCnt = Get-WmiObject Win32_Processor | Select-Object -ExpandProperty NumberOfCores
# Define hashtables and Insert Records
$myHash = @{}
$myHash.Add("OS",$OsName)
$myHash.Add("OsVersion",$OsVersionValue)
$myHash.Add("Hostname",$HostName)
$myHash.Add("IP Address",$ip.ipaddress[0])
$myHash.Add("Processors",$OSProcessorCnt)
#$myHash
# export $myHash into .\test.txt
foreach ( $myKey in $myHash.Keys ) { add-content .\test.txt ('"' + $myKey + '"' + ':' + '"' + $myHash.$mykey + '"') }
# convert NewLine of test.txt and export to result.txt
(Get-Content .\test.txt) -join ',' | Out-File -FilePath .\result.txt -Force
type .\result.txt
@giseongeom
Copy link
Author

PS > gather-system-info-and-hashoutput.ps1

"Processors":"4","OsVersion":"Microsoft Windows 11 Enterprise 64-bit en-US","IP Address":"10.1.1.1","OS":"Microsoft Windows 11 Enterprise","Hostname":"GISEONG-PC"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment