Powershell - AD computer list

I used to have a script that would report computernames and software loaded on those computers per site.  Ie ad at one location and want a list of computer names and their software listed.  A list of the computer names and os is fine too for now or just a list of the computer names.  I know I could look at DHCP or DNS, but one not all machines are leased or reserved the other DNS shows for all locs overall not just that location computer name/objects.  Thank you.
dee30Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Will SzymkowskiSenior Solution ArchitectCommented:
Use the following script to get all of the computers with Computer name and OS version.

import-module activedirectory
Get-ADComputer -Filter * -Properties name, OperatingSystem | Select Name, OperatingSystem |
Export-csv "c:\computers.csv" -nti

Open in new window


Will.
0
dee30Author Commented:
Can it be specific really to just authenticated users in that lan dc?   Turns out to start that's what I need.  Thx
0
Will SzymkowskiSenior Solution ArchitectCommented:
You can query based on IP address so if you provide me with the IP address you will be able to find all machines with a specific starting IP address i.e. 192.168.10.x etc.. If this is correc you can use the following script below.

import-module activedirectory
$IP = "192.168.10.*"
Get-ADComputer -Filter * -Properties name, OperatingSystem, IPv4Address | ? { $_.IPv4Address -like $IP } | Select Name, OperatingSystem, IPv4Address |
Export-csv "c:\computers.csv" -nti

Open in new window


Change $IP = ""  to whatever IP address you want to query on based on the LAN you are searching for.

Will.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ON-DEMAND: 10 Easy Ways to Lose a Password

Learn about the methods that hackers use to lift real, working credentials from even the most security-savvy employees in this on-demand webinar. We cover the importance of multi-factor authentication and how these solutions can better protect your business!

dee30Author Commented:
last one is ending at >> looking for some other critieria or source I believe...
0
dee30Author Commented:
additionally, not sure how specific if any the last ps query be to nodes 'authenticated' to the dc per say, not just nodes within the subnet specified.  Thank you.
0
Will SzymkowskiSenior Solution ArchitectCommented:
Did you copy the script exactly as i have illustrated? I have tested this and it works completely fine.

Can you post a screenshot of exactly what you are doing?

You need to copy/paste the script into notepad and save the file as a .PS1 file extension. You cannot simply copy this into a powershell session. If you want to do this you need to use the Powershell ISE.

Will.
0
Will SzymkowskiSenior Solution ArchitectCommented:
in the script I am using Get-ADComputer because that is what you had asked in your original question.

Will.
0
dee30Author Commented:
I will create the .pst file an copy/past... I typed it real quick and double checked it... but never know... thx
0
dee30Author Commented:
meant .ps1 file to run...
0
dee30Author Commented:
Was my typing.... seems to have worked once as a .ps1 save and am getting nodes that are actual stations that would be authenticating... thank you.
0
Will SzymkowskiSenior Solution ArchitectCommented:
Perfect. You also may need to set your execution policy as well to ensure the script will run.

Set-executionPolicy remotesigned


Also when you run the PS1 script you need to open powershell, from there navigate to where the script is located, then type .\filename.ps1 and then press enter then the script will run.

Because we are exporting the csv the screen will not show any results. Check the csv when completed.

Will.
0
dee30Author Commented:
All done, known.... Thank you though.
0
Will SzymkowskiSenior Solution ArchitectCommented:
Ok perfect, glad it worked for you.

Will.
0
dee30Author Commented:
Thank you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.