I am try to execute a PowerShell command to get the memory usage and get the result.
import subprocess
output = subprocess.call(["powershell.exe", "Get-Counter -Counter "+'"\memory\\available mbytes"'+" -MaxSamples 10 -SampleInterval 1"])
try:
subprocess.check_output("Get-Counter -Counter "+'"\memory\\available mbytes"'+" -MaxSamples 10 -SampleInterval 1", shell=TRUE)
except subprocess.CalledProcessError, e:
print "subproces CalledProcessError.output = " + e.output
print output
It is success to execute the command, but only get the following result:
subproces CalledProcessError.output =
0
How can I get the PowerShell result back?
Get-Counter -Counter "\memory\available mbytes" -MaxSamples 10 -SampleInterval 1) work in an interactive powershell session?