Post

System Info Ps-Vbs

# title
$title = @"
GULER System Info
--------------------------------
"@

# Ip
$ipAddress = (Test-Connection -ComputerName $env:COMPUTERNAME -Count 1).IPv4Address.IPAddressToString

# Compname
$computerName = $env:COMPUTERNAME

# RAM
$ram = Get-CimInstance -ClassName Win32_PhysicalMemory | Measure-Object -Property Capacity -Sum | ForEach-Object { "{0:N2} GB" -f ($_.Sum / 1GB) }

# CPU
$cpu = Get-WmiObject -Class Win32_Processor | Select-Object -ExpandProperty Name

# Export file etc.
$outputFilePath = "$env:USERPROFILE\Desktop\SystemInfo.txt"

# Post file
"$title`r`n" + @"
Bilgisayar IP adresi: $ipAddress
Bilgisayar ismi: $computerName
RAM: $ram
CPU: $cpu
"@ | Set-Content -Path $outputFilePath -Encoding utf8
' System Info
title = "GULER System Info" & vbCrLf & "--------------------------------"

' IP Address
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")

' Collecting all IPv4 addresses
Dim ipAddresses
ipAddresses = ""

For Each objItem in colItems
If Not IsNull(objItem.IPAddress) Then
For Each strIPAddress in objItem.IPAddress
If InStr(strIPAddress, ":") = 0 Then ' IPv4 adreslerini filtrele
ipAddresses = ipAddresses & strIPAddress & ", "
End If
Next
End If
Next

' Remove the last comma and space
If Len(ipAddresses) > 0 Then
ipAddresses = Left(ipAddresses, Len(ipAddresses) - 2)
End If

' Computer Name
computerName = CreateObject("WScript.Network").ComputerName

' RAM
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory")
totalRAM = 0
For Each objItem in colItems
totalRAM = totalRAM + objItem.Capacity
Next
ram = FormatNumber(totalRAM / (1024 * 1024 * 1024), 2) & " GB"

' CPU
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
For Each objItem in colItems
cpu = objItem.Name
Next

' Disk Serial Number
Set colDisks = objWMIService.ExecQuery ("Select * from Win32_DiskDrive")
For Each objDisk in colDisks
diskSerial = objDisk.SerialNumber
Next

' User Info
Set objNetwork = CreateObject("WScript.Network")
domain = objNetwork.UserDomain
username = objNetwork.UserName

' Output file
outputFilePath = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\SystemInfo.txt"

' Write to file
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(outputFilePath, True)
objFile.WriteLine title

' Write IP addresses
objFile.WriteLine "Bilgisayar IP: " & ipAddresses

objFile.WriteLine "Bilgisayar Adı: " & computerName
objFile.WriteLine "RAM: " & ram
objFile.WriteLine "CPU: " & cpu
objFile.WriteLine "Disk Seri Numarası: " & diskSerial
objFile.WriteLine "Etki Alanı: " & domain
objFile.WriteLine "Kullanıcı Adı: " & username
objFile.Close
This post is licensed under CC BY 4.0 by the author.