Building an Active Directory Inventory – Part 1

There are few parts to building an automated Active Directory Inventory.  We need to be able to inventory the DCs and pull general OS information, pull the NTDS.Dit, and any FSMO roles that they hold.  The second part of this series will cover querying the domain to find what Microsoft OSs are being used in the environment.  Not all that important for most people, but something my management is always asking for. The third part will cover Forest/Domain information and pull the other parts together, into one report.

Again, I put all my functions into a separate file called StoredFunctions.ps1, this way I can call them from any file and reuse over and over again.

This first part will pull the following information from each DC in the domains:

  • Enabled
  • HostName
  • IP
  • DomainName
  • FQDN
  • OS
  • OSVersion
  • SPLevel
  • LastBoot
  • InfrastructureMaster (Does it hold the FSMO Role)
  • PDCEmulator (Does it hold the FSMO Role)
  • RIDMaster (Does it hold the FSMO Role)
  • DomainNamingMaster (Does it hold the FSMO Role)
  • SchemaMaster (Does it hold the FSMO Role)
  • GlobalCatalog
  • Site
  • NTDSLocation
  • NTDSSize
  • NetLogon
  • SYSVOL
  • OtherShares
  • DN

You will be able to call this separately or together with the master inventory function.

When Export-CSV is not enough

Creating richer reports, when Export-CSV is not enough

I needed something more than the simple Export-CSV.  While it is very useful and quick, I needed something that I could add additional worksheets to and be management ready.  I found this code to create an Excel spreadsheet.  I modified the code to be in a function format and to fit my needs.  Now I can export any data from PowerShell into a nicely formatted Excel file.

To add another worksheet, I created another function, AddExcelWorkSheet.  This function looks for the Excel variable from the previous function and adds another worksheet.  It follows the same process as the original function.

Now to export data using the new functions:

. PrettyExcelExport $ExcelSheetName, $ExcelSheetTitle, $Columns, $Data, $filename, $CloseExcel

Example:

 

AD Inventory-Domain

AD Inventory

DC Inventory-Domain

DC Inventory

 Tip:  When exporting the data to Excel using the functions above, export the worksheet you want first, last.

SharePoint Site Disk Space Usage

I often have the need to help clients figure out why their SharePoint site collection is so large or the best way to break sites into new site collections. SharePoint doesn’t offer an easy way to figure out the size of each site in a site collection and I didn’t have the time to figure out how to write a PowerShell script. So I had to think outside of the box.

One of my favorite daily tools is WinDirStat. It a tool that will give you a graphical view of disk usage. You can select disk drives or even narrow it down to one specific folder. So how can we utilize this for SharePoint sites?

SharePoint utilizes a technology called WebDav. This allows us to open up SharePoint as a folder in Windows Explorer and view all the files as we would on an Operating System.

So I opened up SharePoint to the site collection I wanted to get the space usage with in Windows Explorer.

WebDav

Then I open up WinDirStat and enter in the path into the folder selection. Click Ok, and let it run.

WinDirStat

It does take while, but you will get a nice report when it is finished. I just let it run over night. Note: I was running this over a VPN.  It should be faster if you are on-site.

This is the report you end up with:

WestPoint WinDirStat