Solved

Active Directory Inventory

Posted on 2014-10-20
3
126 Views
Last Modified: 2014-10-28
see any issues? i know i am missing dc= but other then that?


import-module activedirectory

$results = @()
$computers = Get-ADComputer -Filter * -SearchBase "OU=Servers,DC=,DC=,DC=global" | select -expandproperty name
foreach ($computer in $computers) {
$results += Get-WmiObject Win32_ComputerSystemProduct -ComputerName $computer| Select @{Name="Computer Name";Expression={$computer}},Vendor,Name,IdentifyingNumber
}
$results | Export-CSV C:\ComputerInfo.csv -nti
0
Comment
Question by:Jorge Ocampo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 16

Assisted Solution

by:Joshua Grantom
Joshua Grantom earned 250 total points
ID: 40393305
what was the error you got when running it Jorge? I tested the original script on my network and it worked.

I would make sure your searchbase is an actual OU and not just a container.
Right-Click on the Server (OU or COntainer) and select properties. Go to the Attribute Editor and find distinguishedname. Does it have an OU= or a CN= next to Servers?

Also, to see the attribute editor you have to make sure that you have advanced features selected under the view menu in ADUC
0
 
LVL 16

Expert Comment

by:Joshua Grantom
ID: 40393324
You also may have to many DC's in there

most environments do not have sub domains. It would most likely be

OU=Servers,DC=mydomain,DC=global

meaning your domain is mydomain.global
0
 
LVL 6

Accepted Solution

by:
Vipin Vasudevan earned 250 total points
ID: 40394886
Practically this gonna work for you unless you don't have any issue with WMI access to all all server. If any Opaddition error can be avoided by making $results as array as below

[array]$results += Get-WmiObject Win32_ComputerSystemProduct -ComputerName $computer| Select @{Name="Computer Name";Expression={$computer}},Vendor,Name,IdentifyingNumber

if any WMI error for me below comment works perfect for me

"Invoke-Command {Get-WmiObject Win32_ComputerSystemProduct} -computer $computer"
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question