0
I am trying to create a remote, WMI query script that will query a bunch of machines and tell me the MemoryChip configuration information. This way, we can find out what machines physically have 1 chip or 2 chips and how big each one is and find out who has a 1x4GB configuration and get them upgraded. The base I am running is: wmic /node:"[ComputerName]" MEMORYCHIP get BankLabel,DeviceLocator,Capacity,Tag > memory.txt
The problem is that this just kicks out the following, which provides no ability to reference the computer being queried:
BankLabel Capacity DeviceLocator Tag
4294967296 DIMM A Physical Memory 0
4294967296 DIMM B Physical Memory 1
You run this 50x, and there's not a quick way to find out which machine has what. What I am trying to do is have the script Echo the "ComputerName" to the line preceding the text or append it at the next line. All of my efforts to do this have not produced viable results, so I am hoping at least one person who still uses batch (for things, quite frankly, I should learn powershell to execute) can help me with this.
What are you passing to
/node
- a list of machine IDs or a single ID? – Karan – 2015-06-12T16:03:42.937Right now, it is 1 machine per line. So each time we query a new machine, we start a new WMIC line.
TL;DR - One machine per /Node switch – SplatteredShrapnel – 2015-06-12T16:53:50.597
Ok, so why not echo each machine ID to the text file before redirecting WMIC's output to the same file? – Karan – 2015-06-12T16:57:23.013
@Karan I tried that.
echo ... > file
followed bywmic ... >> file
sticks a load ofNUL
s in file. Example "[ComputerName] ÿþB a n k L a b e l ", etc where the spaces areNUL
s. Hence my answer usingwmic
twice. – DavidPostill – 2015-06-12T17:03:01.977echo
andwmic
together redirecting to the same file seems to be a no no. Something to do with character sets maybe? – DavidPostill – 2015-06-12T17:04:36.933echo output is "ASCII text, with CRLF line terminators" and wmic output is "Little-endian UTF-16 Unicode text, with CRLF line terminators" – DavidPostill – 2015-06-12T17:23:29.917