I have written this script to extract the PC's and servers from the AD into two differnet spreadsheets. But whenever I run the script, I'am getting the following error. Can anyone help me by pointing out on where I am going wrong.
This is the error I am getting :
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
Given below is the script :-
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