Find cpu information in linux via script

ssh root@server.corp.com "bash -s" /tmp/server_cpu.txt

insert less than and greater symbols that include getcpu.sh after "bash -s" above

Save the following as getcpu.sh

cat /proc/cpuinfo | \
awk -v FS=':' ' \
/^physical id/ { if(nb_cpu<$2) { nb_cpu=$2 } } \
/^cpu cores/ { if(nb_cores<$2){ nb_cores=$2 } } \
/^processor/ { if(nb_units<$2){ nb_units=$2 } } \
/^model name/ { model=$2 } \
\
END{ \
nb_cpu=(nb_cpu+1); \
nb_units=(nb_units+1); \
\
print "CPU model:",model; \
print nb_cpu,"CPU,",nb_cores,"physical cores per CPU, total",nb_units,"logical CPU units" \
}'

vbscript based computer inventory scripts

strComputer = “.” Set objWMIService = GetObject(“winmgmts:” _     & “{impersonationLevel=impersonate}!\\” _     & strComputer & “\root\cimv2”) Set colOperatingSystems = objWMIService.ExecQuery _     (“Select * from Win32_OperatingSystem”) For Each objOperatingSystem in colOperatingSystems     Wscript.Echo objOperatingSystem.Caption & _     ”  ” & objOperatingSystem.Version Next

strComputer = “.” Set objWMIService = GetObject( _     “winmgmts:\\” & strComputer & “\root\cimv2”) Set IPConfigSet = objWMIService.ExecQuery _     (“Select IPAddress from Win32_NetworkAdapterConfiguration” _         & ” where IPEnabled=TRUE”)   For Each IPConfig in IPConfigSet     If Not IsNull(IPConfig.IPAddress) Then         For i=LBound(IPConfig.IPAddress) _         to UBound(IPConfig.IPAddress)             WScript.Echo IPConfig.IPAddress(i)         Next     End If Next

Get active directory role with vbscript

sComputer = “.” WScript.Echo DomainRole(sComputer)

Function DomainRole(sNode) Set oWMI = GetObject(“winmgmts:” _ & “{impersonationLevel=impersonate}!\\” & sNode & “\root\cimv2”) Set colComputer = oWMI.ExecQuery _ (“Select DomainRole from Win32_ComputerSystem”) For Each oComputer in colComputer iDR = oComputer.DomainRole Next

Select Case iDR Case 0 DomainRole = “Standalone Workstation” Case 1 DomainRole = “Member Workstation” Case 2 DomainRole = “Standalone Server” Case 3 DomainRole = “Member Server” Case 4 DomainRole = “Backup Domain Controller” Case 5 DomainRole = “Primary Domain Controller” Case Else DomainRole = “Unknown” End Select

End Function

vbscript to copy file to multiple computers from list

Const ForReading = 1
Const OverwriteExisting = TRUE

Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set objFile = objFSO.OpenTextFile(“C:\Computers.txt”)

Do Until objFile.AtEndOfStream
strComputer = objFile.ReadLine
strRemoteFile = “\\” & strComputer & “\C$\example.vbs”
objFSO.CopyFile “C:\example.vbs”, strRemoteFile, OverwriteExisting
Loop