0
컴퓨터의 AD 속성을 지우고 있습니다. 그런 다음 속성을 일부 값으로 변경하려고합니다. 그러나 속성은 내가 그 AD 개체의 속성을 볼 때 더 이상 존재하지 않는 것 같습니다 :Powershell - 지운 후에 활성 디렉토리 속성을 검색 할 수 없습니다.
function clearAttribute
{
$directorySearcher = New-Object System.DirectoryServices.DirectorySearcher
$directorySearcher.PageSize = 100
$directorySearcher.SearchScope = [System.DirectoryServices.SearchScope]::Subtree
$directorySearcher.Filter = "(&(objectCategory=computer)(cn=computerName1))"
$result = $directorySearcher.FindOne()
if ($result.Properties.Contains("netbootmachinefilepath"))
{
$directoryEntry = $result.GetDirectoryEntry()
$directoryEntry.Properties["netbootmachinefilepath"].Clear()
$directoryEntry.CommitChanges()
}
}
function setAttribute
{
$directorySearcher = New-Object System.DirectoryServices.DirectorySearcher
$directorySearcher.PageSize = 100
$directorySearcher.SearchScope = [System.DirectoryServices.SearchScope]::Subtree
$directorySearcher.Filter = "(&(objectCategory=computer)(cn=computerName1))"
$result = $directorySearcher.FindOne()
if ($result.Properties.Contains("netbootmachinefilepath")) ###THIS IS FALSE!###
{
$directoryEntry = $result.GetDirectoryEntry()
$directoryEntry.Properties["netbootmachinefilepath"].Value = "someValue"
$directoryEntry.CommitChanges()
}
}
clearAttribute
setAttribute
편집 :은 (는 비워 둘 수 없습니다)이 속성이 아닌 빈 또는 삭제 될 수 있습니다 밝혀졌습니다. 값을 "지우려면"값을 갱신하려면 다시 작성해야합니다.