Get deactivated computers in ad from csv list

Mitglied: natalie.solero
Hello guys,

i'm tryin to figure out which computers are deactivated in active directory. for that i provide the computer names in a csv list. i just want to output the computers which are deactivated. this is what i have. unfortunately i get all deactivated computers. but i only want that names provided in the csv.


Content-Key: 1128828179

Url: https://administrator.pro/contentid/1128828179

Printed on: September 23, 2021 at 10:09 o'clock

Mitglied: Xaero1982
Xaero1982 Aug 06, 2021 updated at 09:16:11 (UTC)
Goto Top
Hi,

if you only want the name:


If you also want the OS


Mitglied: natalie.solero
natalie.solero Aug 06, 2021 at 08:58:22 (UTC)
Goto Top
Hi @Xaero1982, thank you for your reply. My Problem is, i don't want all pc names in the provided OU searchbase, i just want the names of the deactivated computers i have in the provided csv file
Mitglied: Xaero1982
Xaero1982 Aug 06, 2021 at 09:03:13 (UTC)
Goto Top
Sure i forgot the first import-csv. I will correct it
Mitglied: 149062
149062 Aug 06, 2021 updated at 09:11:24 (UTC)
Goto Top

Mitglied: natalie.solero
natalie.solero Aug 06, 2021 at 09:16:49 (UTC)
Goto Top
at first the filter was missing. after I inserted this i still get all diabled pc names in the provided ou :-( face-sad
Mitglied: Xaero1982
Xaero1982 Aug 06, 2021 at 09:26:13 (UTC)
Goto Top
I have created a pc_names.csv


PC1 is disabled.

I use this one

and I got a file DisabledComps.csv with PC1 and Windows 10 Pro.

How does your importfile looks like? And whats the suffix of your file?
Mitglied: natalie.solero
natalie.solero Aug 06, 2021 updated at 13:22:40 (UTC)
Goto Top
i have a normal csv file without the name header.

pc1
pc2
pc3

i tried your code with and without a header in my csv file.
if i add the name header, i get a csv with all pc names in it again and the following message. i work with a german system, so i don't exactly understand

Get-ADComputer : The input object cannot be bound to any parameters of the command because the command does not accept pipeline input or the input and its properties do not match any of the parameters that accept pipeline input.
In line:1 Character:61
Mitglied: 149062
149062 Aug 06, 2021 updated at 09:53:46 (UTC)
Goto Top
If you dont have a header in your file then you don't need import-csv and you can use Get-Content or you need to specify the -header Parameter with import-csv
or

Mitglied: natalie.solero
natalie.solero Aug 06, 2021 updated at 13:23:44 (UTC)
Goto Top
Hi @149062,
when i run your code, i prompted to specify a filter. i used Enabled -eq $False. after that i get the exported csv with all deactivated pc's inside, not only with the provided names inside the .txt file -> your code example 2
after the code finished i get the following failure:

Get-ADComputer : The input object cannot be bound to any parameters of the command because the command does not accept pipeline input or the input and its properties do not match any of the parameters that accept pipeline input.
Mitglied: 149062
149062 Aug 06, 2021 updated at 10:22:48 (UTC)
Goto Top
Zitat von @natalie.solero:

Hi @149062,
when i run your code, i prompted to specify a filter. i used Enabled -eq $False. after that i get the exported csv with all deactivated pc's inside, not only with the provided names inside the .txt file -> your code example 2
after the code finished i get the following failure

Get-ADComputer : Das Eingabeobjekt kann an keine Parameter des Befehls gebunden werden, da der Befehl keine Pipelineeingaben akzeptiert oder die Eingabe und deren Eigenschaften mit keinem der Parameter
übereinstimmen, die Pipelineeingaben akzeptieren.

No, runs here without problems if you use a current powershell version! When one ore more string arguments are transmitted via pipeline Get-ADComputer switches to another parameterset, and -Filter is not a member! So is works as designed ;-) face-wink.

If you don't tell us the real content of your text file we cannot help, because here it works as expected, when the textfile only contains the SamAccountNames of the computers.
Mitglied: natalie.solero
natalie.solero Aug 06, 2021 at 10:22:35 (UTC)
Goto Top
i just have tried it with a csv file and a text file where i have just the computernames written in each row like
pc1
pc2
pc3
...
without header
Mitglied: 149062
149062 Aug 06, 2021 updated at 11:31:02 (UTC)
Goto Top
Quote from @natalie.solero:

i just have tried it with a csv file and a text file where i have just the computernames written in each row like
pc1
pc2
pc3
...
without header

As i said not a problem, have a look

screenshot

screenshot

screenshot

Works as designed!

I'm out.