Hello Team,
The below is the script I gave to pull the computer accounts and details for AD. But I get error as
"
Get-ADComputer : The server has returned the following error: invalid enumeration context.
At C:\Temp\Scripts\All computer details.ps1:1 char:15
+ Get-ADComputer <<<< -Filter * -SearchBase "OU=WP360,OU=P001,OU=CLI,OU=Data,DC=eric,DC=se" |select name -ExpandProperty Name |out-file c:\temp\output\com11.txt
+ CategoryInfo : NotSpecified: (:) [Get-ADComputer], ADException
+ FullyQualifiedErrorId : The server has returned the following error: invalid enumeration context.,Microsoft.ActiveDirectory.Management.C
ommands.GetADComputer
"
My Script is below:
***********************************
Get-ADComputer -ldapFilter (objectclass=computer) -SearchBase "OU=WP360,OU=P001,OU=CLI,OU=Data,DC=erics,DC=se" | select name -ExpandProperty Name |out-file c:\temp\output\com11.txt
$array = Get-Content c:\temp\output\com11.txt
foreach ($a in $array)
{
$q = $a | foreach {$_[2]}
if ($q -ge 48 -and $q -le 57)
{
$x=$a|out-file c:\Temp\output\xxxx.txt -Append
}
else
{
}
}
$computers = get-content c:\Temp\output\xxxx.txt
foreach ($comp in $computers)
{
get-adcomputer -identity $comp -properties * | select cn,distinguishedName,dnshostname,dscorepropagationdata,employeeID,InstanceType,lastlogoff,lastlogon,lastlogontimestamp,logoncount,msds-authenticatedAtDC,name,objectcatehory,operatingSystem,Operatingsystem
servicepack,operatingsystemversion,Samaccountname,samaccounttype,serial,streetAddress,whenchanged,whencreated |Export-Csv c:\Temp\output\computerdetails.csv
}
So I want all the attributes listed for the computer that starts with two character followed by a number (eg: AH965645).
Note : There are more than a lakh of computer object in this OU
Please help me to correct the script so that I can use it to pull the information required.
Regards,
Suman Rout