컴퓨터가 Windows 도메인의 일부인지 알고 싶다면 Win32_NTDomain
WMI 정보를 얻을 수 있습니다.
PowerShell에서이 제공 :
Get-WmiObject Win32_NTDomain
ClientSiteName : Default-First-Site-Name
DcSiteName : Default-First-Site-Name
Description : DOM
DnsForestName : dom.fr
DomainControllerAddress : \\192.168.183.100
DomainControllerName : \\WM2008R2ENT
DomainName : DOM
Roles :
Status : OK
판 @ScottTx 의견에 따라 당신은 또한 당신이 그것을 얻을 수있는 C#으로 Win32_NTDomain class documentation에 따르면 Win32_ComputerSystem
WMI 클래스
PS> (Get-WMIObject Win32_ComputerSystem).PartOfDomain
False
을 사용할 수 있습니다 작성자 :
using System;
using System.Collections.Generic;
using System.Text;
using System.Management;
namespace WMIQuery
{
class WmiQuery
{
static void Main(string[] args)
{
ManagementObjectSearcher domainInfos = new ManagementObjectSearcher("select * from WIN32_NTDomain");
foreach (ManagementObject domainInfo in domainInfos.Get())
{
Console.WriteLine("Name : {0}", domainInfo.GetPropertyValue("Name"));
Console.WriteLine("Computer/domain : {0}", domainInfo.GetPropertyValue("Caption"));
Console.WriteLine("Domain name : {0}", domainInfo.GetPropertyValue("DomainName"));
Console.WriteLine("Status : {0}", domainInfo.GetPropertyValue("Status"));
}
// Edition according to @ScottTx comment you can also use `Win32_ComputerSystem` WMI class
ManagementObjectSearcher ComputerInfos = new ManagementObjectSearcher("select * from Win32_ComputerSystem");
foreach (ManagementObject ComputerInfo in ComputerInfos.Get())
{
if ((bool)ComputerInfo.GetPropertyValue("PartOfDomain"))
Console.WriteLine("This computer is part of domain");
else
Console.WriteLine("This computer is not part of domain");
}
}
}
}
는 System.Management
조립
Win32_ComputerSystem.PartOfDomain은 true/false를 반환합니다. 어느 쪽이든 작동합니다. – ScottTx