Jump to content

Recommended Posts

Posted

Hi,

I need to run a script on individual machines that'll not only tell me how much RAM said machines have, but how much is loaded into each slot and which slots (if any) are free. I found a great VBscript written by a Microsoft scripting guy but its downside was that although it worked, every time the script was run it overwrote the CSV file it was writing into. Maybe I was using it incorrectly but I kinda gave up on that one. I have also tried with Spiceworks which tells you how much RAM a machine has, but no information about DIMM slots.

 

Has anyone else had to do this? Could anyone suggest a way of doing this please? I'm learning Powershell atm so anything PS based would be a huge bonus.

 

many thanks

Posted

It looks good and probably just needs a tweak I assume you want all the computers to write to one log file that you can analyse?

 

Ben

Posted

have a script somewhere that records that BUT it dosent always do it accuraely sometimes wht the board reports via wmi is not correct

 

'On Error Resume Next
ramsticks = ""
strComputer = "."
Set wshShell = WScript.CreateObject( "WScript.Shell" )
' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory")
For Each objItem in colItems
ramsticks = ramsticks & " , " & objItem.Capacity / 1073741824 & "gb"
Next


dim bankCount
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

strWQL = "select * from Win32_MemoryDevice"
Set objInstances = objWMI.ExecQuery(strWQL,,48)

bankCount=0
For Each objInstance in objInstances
 bankCount=bankCount+1
Next
wscript.echo ramsticks &  " , " & bankCount & " slots"
ramdata = ramsticks &  " , " & bankCount & " slots"

'write file location
pcname = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
strDirectory = "\\server\logs$\ram\"
strFile = pcname & ".csv"

' Check that the strDirectory folder exists
If objFSO.FolderExists(strDirectory) Then
  Set objFolder = objFSO.GetFolder(strDirectory)
Else
  Set objFolder = objFSO.CreateFolder(strDirectory)
  'WScript.Echo "Just created " & strDirectory
End If

If objFSO.FileExists(strDirectory & strFile) Then
  Set objFolder = objFSO.GetFolder(strDirectory)
Else
  Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
  'Wscript.Echo "Just created " & strDirectory & strFile
End If 

set objFile = nothing
set objFolder = nothing
' OpenTextFile Method needs a Const value
' ForAppending = 8 ForReading = 1, ForWriting = 2
Const ForAppending = 2

Set objTextFile = objFSO.OpenTextFile _
(strDirectory & strFile, ForAppending, True)

' Writes result every time you run this VBScript
objTextFile.WriteLine(ramdata)
objTextFile.Close

Posted

Thanks guys.

It looks good and probably just needs a tweak I assume you want all the computers to write to one log file that you can analyse?

Yeah that's right. I checked it again today and it seems to have stopped overwriting which is a good thing. It just seems a little temperamental.

 

If Spiceworks can do this as a report can someone show me how? I know you can find out how many DIMM slots are occupied via the Spiceworks interface, but can this info be exported into a CSV?

Posted

WinAudit v2.29 - Free Computer Audit Software

This is what we use. I've written a script which runs the scan at startup only if it hasn't been run for this particular machine before. Each PC gets its audit logged to an individual CSV file (named after the PC) and if that CSV file exists, the audit doesn't run. The audit contains all hardware and software related to that PC. Plenty of command line options so you can tailor what it does to your requirements. Hope this helps.

  • 6 months later...
Posted
Google Project fog, set a server up on any machine (linux box) this is a web interface imaging system completely free and open source. it does much more than you need but this will list everything you need on every client computer. also install nedi and this will audit all your network stuff.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...