I want to check if a computer is in a domain or in a workgroup using python
for example:
def run_check():
# code here
result = run_check()
if result == "Domain":
print("Domain")
elif result == "Workgroup":
print("Workgroup")
else:
print("None")
I tried using os.environ['USERDNSDOMAIN'] but it gives either WorkGroupName or DomainName and I cant tell if the name is for a Workgroup or a Domain
Can you help me out?
Thanks in advance
Apply Windows Management Instrumentation (
wmimodule):Note:
print(wmi_os)shows all properties (and their values) of theWin32_ComputerSystemclass instance.All properties are
print(wmi_os.__dict__['properties'].keys())You could be interested mainly in following ones: