Nov 22 2021 10:49 AM - edited Nov 22 2021 11:13 AM
Hi!
I am trying to create a script that will retrieve all computers but exclude any servers found. I also discovered that using the most basic command will return about two dozen servers and then crash with the error message shown below:
get-adcomputer -Filter * -Properties * -Server "MyServer.com"
Output:
get-adcomputer : Directory object not found
At line:1 char:1
+ get-adcomputer -Filter * -Properties * -Server "MyServer.com" | ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (:) [Get-ADComputer], ADIdentityNotFoundException
+ FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException,Microsoft.ActiveDire
ctory.Management.Commands.GetADComputer
Here are some command lines I have tried with no success:
get-adcomputer -Filter * -Properties * -Server "MyServer.com" | Select-Object cn,operatingsystem,canonicalname
get-adcomputer -Filter * -Properties * -Server "MyServer.com" | where-object {($_.OperatingSystem -notlike "*Server*")} | select-object cn, operatingsystem
get-adcomputer -Filter * -Properties * -Server "MyServer.com" | where-object ($_.OperatingSystem -notlike "*Server*") | select-object cn, operatingsystem
get-adcomputer -Filter 'OperatingSystem -ne "*Server*"' -Properties cn,operatingsystem | select-object cn, operatingsystem
get-adcomputer -Filter ('OperatingSystem -notlike "*Server*"') -Properties cn,operatingsystem | select-object cn, operatingsystem
I'm not sure what the error message means and I can't seem to filter out servers. Shouldn't Get-ADComputer be able to get all computers without any errors?
Thank you!
Rob
Nov 22 2021 03:52 PM
Nov 22 2021 04:05 PM
Nov 23 2021 09:41 AM
Nov 23 2021 10:49 AM