2017-11-20 2 views
1

나는이 스크립트를 작성하여 AD의 PC와 서버를 두 개의 differnet 스프레드 시트로 추출했습니다. 하지만 스크립트를 실행할 때마다 다음 오류가 발생합니다. 누군가 내가 잘못 가고있는 것을 지적함으로써 나를 도울 수 있습니까? 스크립트 아래Powershell - 조건부 연산자

Get-ADComputer : The server has returned the following error: invalid enumeration context. 
At line:3 char:1 
+ Get-ADComputer -filter { OperatingSystem -ne '*server*' -OR Operating ... 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : NotSpecified: (:) [Get-ADComputer], ADException 
    + FullyQualifiedErrorId : The server has returned the following error: invalid enumeration context.,Microsoft.ActiveDirectory.Management.Commands.GetADComputer 

Get-ADComputer : The server has returned the following error: invalid enumeration context. 
At line:6 char:1 
+ Get-ADComputer -filter { OperatingSystem -eq '*server*' -OR Operating ... 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : NotSpecified: (:) [Get-ADComputer], ADException 
    + FullyQualifiedErrorId : The server has returned the following error: invalid enumeration context.,Microsoft.ActiveDirectory.Management.Commands.GetADComputer 

됩니다 :

내가 점점 오전 오류입니다 - 내 조직에 적응 할 때

import-module ac* 

Get-ADComputer -filter { OperatingSystem -ne '*server*' -OR OperatingSystemVersion -Like '*5.1*' -OR OperatingSystemVersion -Like '*6.1*' -and Enabled -eq "true"} -SearchBase 'OU=IMComputers,OU=IM,dc=image,dc=inter' -Properties '*' | Select Name,OperatingSystem,Status, OperatingSystemVersion, ` 
LastLogonDate,CanonicalName | Export-Csv -NoType "C:\Temp\PC's in AD" -Encoding UTF8 

Get-ADComputer -filter { OperatingSystem -eq '*server*' -OR OperatingSystemVersion -Like '*5.0*' -OR OperatingSystemVersion -Like '*5.2*' -OR OperatingSystemVersion -Like '*6.0*' -OR OperatingSystemVersion -Like '*6.1*' -OR OperatingSystemVersion -Like '*6.2*' -OR OperatingSystemVersion -Like '*6.3*' -and Enabled -eq "true"} -SearchBase 'OU=IMComputers,OU=IM,dc=image,dc=inter' -Properties '*' | Select Name,OperatingSystem,Status, OperatingSystemVersion, ` 
LastLogonDate,CanonicalName | Export-Csv -NoType "C:\Temp\Servers in AD" -Encoding UTF8 

답변

1

스크립트가 작동하므로 (이 작은 하나) 너는 그렇게 잘못되지 않는다. 그러나 나는 몇 년 전에 그걸 읽었고 G 덕분에 .... 내 친구 나는 Invalid Enumeration Context using powershell script to check computer accounts을 발견했다.

요약 : 색인이 생성되지 않은 특성을 기반으로 쿼리하면 문제가 심각해집니다. operatingSystem 및 operatingSystemVersion 속성은 색인화되지 않습니다. 도메인에 많은 수의 컴퓨터 개체가 있고 OS를 기반으로 자주 쿼리한다고 가정하면 운영 체제를 인덱싱하는 것이 좋습니다. 다른 해결책은 Get-ADComputer 대신 LDAP 필터와 함께 DirectorySearcher 필터를 사용하는 것입니다.