powershell Active Directory获取当前的域功能

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell Active Directory获取当前的域功能相关的知识,希望对你有一定的参考价值。

function getDomain
{
	#Reading current Active Directory
	$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
	$objSearcher.PageSize = 1
	$objSearcher.Filter = "(objectclass=Domain)"
	$objSearcher.SearchScope = "Subtree"
	$currentActiveDirectory = $objSearcher.FindAll()
	
	$LocalDomain = ($currentActiveDirectory.path).replace(",DC=", ".").replace("LDAP://DC=", "")
	$path = $currentActiveDirectory.path
	
	WriteLogFile "function: getDomain - Scriptrunning Domain is $LocalDomain"
	return $LocalDomain, $path
}

以上是关于powershell Active Directory获取当前的域功能的主要内容,如果未能解决你的问题,请参考以下文章