Table of Contents

Introduction

A lot of usable information like Location, Company or responsible Department are often already stored in Active Directory.
So why not using that data to extend the "Microsoft.Windows.Computer" Class by a Custom Class and PowerShell Discovery?

In this example i will you how to create a class with the new properties and also a sample script to discovery data from Active Directory and return it to SCOM.

Note: I will not cover the basics of VSAE, Class design or PowerShell Discovery Script. For that please refer to following articles:

Create a Class

First of all we have to create a new class which will contain the properties we discover from Active Directory. As we are extending the "Microsoft.Windows.Computer" Class we use it as base Class for out new one.

In this example we use the following attributes from Active Directory for our Class:

Followed by this we create a searcher object and configure the settings for it.$objSearcher=New-ObjectSystem.DirectoryServices.DirectorySearcher$objSearcher.SearchRoot=$objDomain$objSearcher.Filter=$strFilter

In the next step we search for the Computer object and return all values.

Now we parse each single values to a variable and convert it to a string.$Description=($ComputerItem.description).ToString()$Location=($ComputerItem.location).ToString()$Company=
($ComputerItem.company).ToString()$Department=($ComputerItem.department).ToString()$Division=($ComputerItem.division).ToString()

In the last step we create a instance of our class and fill the properties.