Get system inventory (Python)

You can query system information with below script:

import subprocess;
process=subprocess.Popen((‘systeminfo.exe | find /V /I “hotfix” | find /V “KB” ‘),shell=True,stdout=subprocess.PIPE);
for line in iter(process.stdout.readline,’’):
print line.rstrip();

An example output would be:

Hi All,

Just was working on this one at the moment, it requires a tab before the last line otherwise it errors

File “<string>”, line 4 print line.rstrip(); ^ IndentationError: expected an indented block Does this forum support code blocks? this may retain some of the special formatting required by python (I don’t know a lot about it yet)

As dougaust says, the last line needs to be indented.

Like so:

import subprocess;
process=subprocess.Popen(('systeminfo.exe | find /V /I "hotfix" | find /V "KB" '),shell=True,stdout=subprocess.PIPE);
for line in iter(process.stdout.readline,''):
       print line.rstrip();