I'm actually working on a "Computer Info Dumper" and I need to get the ram name + capacity, the problem is that the line that make this: it works in CMD, but not in a .bat file.
Here is the 'command': powershell -command "GWmi CIM_PhysicalMemory|%{\"\"+ ([int]$_.banklabel.Replace('BANK ','') + 1) + \") \" + ($_.capacity/1GB)+\"GB from \"+($_.manufacturer)}"
In CMD, it gives me the wanted result:
8GB from Corsair 4GB from Kingston 8GB from Corsair 4GB from Kingston
But in a .bat file, it gives me this error: (it will be translated because it's in French so the translation won't be perfect)
To character Line:1 : 25
+ ... sicalMemory|{""+ ([int]$_.banklabel.Replace('BANK ','') + 1) + ") " + ...
Expressions are only allowed as the first element of a pipeline.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpressionsMustBeFirstInPipeline
Can anyone help me on that?