Dynamic Infrastructure Documentation with Powershell – Part 3

Here we go again, in this part we are going to get all servers in Active Directory and then we are going to audit them for both applications and services. Note that the snippets in LinkedIn is not very code friendly so bare with me, I will post this blog also on my personal website that I am currently working on and it will have better code snippets. Create a new table in DynamicDocumentationDB named AuditServices this table will contain information on all servers, services that have specific user running i.e. Active Directory user. We will exclude all services that have log on as NT Authority, LocalSystem and if the service has an empty username. Here is the SQL query for creating the table

Open up the DEPMSSQLAction.psm1 and add the following line


Now we will create a new file named AuditServices.ps1 and save it to the tasks folder, this file will enumerate each server which is in Active Directory, check if the server is online and then capture the information about the services. We will also check if the specified service user has not changed his password within 90 days and will add it to the notes field.


As promised in Part 3 we will also enumerate all servers and get software installed. We can do the same as we do above but there is different approach to this so we cannot use the same code. But before we start we need to define what information we are going to collect, lets start with the server information and here is a list that I am going to collect.

  • Server Information
  • Bios Information
  • CPU Information

Create a new Table named OSInformation with this specific columns

Open up the DEPMSSQLActions.psm1 and add the following code. Note that the parameter for this function is pretty long


Now create a new file named AuditServers.ps1 and save it to the Task folder. Open up the file and add the following code.


Now for the Software, create a table named SoftwareInformation by using this query. We will get this information from the os of each computer in active directory.

Open up the DEPMSSQLActions.psm1 and add the following function to add information in the SoftwareInformation table  

Create a new file named AuditSoftware.ps1 and add the following code, note in this example I use the ParseExact date conversion, in AutidServers I used different method.

  Now we have not updated our Debug-SQL.ps1 yet but we can do this now typing in this code  

Now we have completed this part, in next part we will audit Microsoft Exchange server information and also the users.

Trackback from your site.