N
N
Nikolay Baranenko2016-08-27 10:30:37
Python
Nikolay Baranenko, 2016-08-27 10:30:37

How to correctly transfer the domain name of the user?

Hello.
To get the CPU value from a remote windows server I am trying to execute the following code

import re
import wmi
from subprocess import Popen, PIPE

def get_cpu(computer, user, password):
    c = wmi.WMI(computer=computer, user=user, password=password, find_classes=False)
    utilizations = [cpu.LoadPercentage for cpu in c.Win32_Processor()]
    utilization = int(sum(utilizations) / len(utilizations))  # avg all cores/processors
    return utilization

print(get_cpu("webserver01", "newdomain\007user", "password"))

I get an error in
print(get_cpu("webserver01", "newdomain\007user", "password"))
What is the correct way to pass the value of the domain user?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri, 2016-08-27
@drno-reg

I'll try to suggest that you need to escape the slash:

print(get_cpu("webserver01", "newdomain\\007user", "password"))

N
Nikolay Baranenko, 2016-08-27
@drno-reg

the problem was that I was trying to connect to the local PC, prescribing the US.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question