This blog post is part of a series of posts that describe how to build an Active Directory Help Desk tool with PowerShell Universal. Here is a listing of other posts in this series.
The full source code can be found on our template repository.
In this blog post, we will look at how to create a scheduled script to collect some information about computers in our Active Directory domain. Then, we will update our dashboard and take advantage of the charting capabilities of Universal Dashboard to show the information in an easy to digest manner.
Collecting Computer Information
Our computer information script will aggregate three properties that we wish to show as charts in our dashboard. These properties will include Operating System, Operating System Service Pack and Location. First, the script retrieves all computers from Active Directory using Get-ADComputer. The $Computer and $Domain variables are defined as variables within our Universal Automation environment.
We then group by each of the properties we wish to aggregate into our dashboard. We store these values are properties in a PSCustomObject. We write this PSCustomObject to the pipeline for access later.
Now that we have our script developed, we can run it to collect the information. Universal Automation will automatically store the pipeline output so that we can retrieve it within our dashboard.
Scheduling our Script
To schedule a script in Universal Automation, you can click the Automation \ Schedule menu item and then click new schedule. We will schedule our script to run every hour.
With our script scheduled, we can begin working on our dashboard.
Updating the Dashboard
We are using the dashboard from the previous posts in our Active Directory Help Desk series. In this post, we will update the dashboard to have multiple pages and then add charts to a new Dashboard page.
To add new pages to a dashboard, we can use the New-UDPage cmdlet. Each page will have it’s own content. Adding pages will automatically configure navigation.
The navigation will be presented as a hamburger menu on the top level of our dashboard.
I’ve added two pages to our dashboard. The dashboard page will provide the charts for our computer report and the Toolbox page will contain our View User and Reset Password tools.
First, we’ll create a bar chart to show the different types of operating systems in our environment. We use the Get-UAScript, Get-UAJob and Get-UAJobPipelineOutput cmdlets to retrieve the pipeline output from the last job that was run. Job pipeline output is returned as a PSCustomObject so you can just access the properties of it. Next, we pass the data into the -Data parameter of New-UDNivoChart. We select the properties that we want to index by and the keys for the values within the bar chart.
Then resulting chart has a bar for each type of operating system and the height is determined by the number of computers with that operating system.
Using the same steps, we will create a operating system service pack chart. You can view the code for that on our template page. Next, let’s make a pie chart that shows the percentages of computers in our two locations. We have locations in Hailey, ID and Madison, WI. The number of computers in each location will show a slice of the pie.
We’ve already formatted our data correctly in our Computer Report script so now we can just pass that data into the -Data parameter and set the type of chart to Pie.
The resulting pie chart looks like this.
Finally, let’s create a chart that contains the change in computers per location over time. Since the jobs are stored historically in Universal Automation, we can retrieve the last 25 jobs and then put them into a chart the represents changes in time well. In this case, let’s look at using the Nivo Stream chart. We will grab the last 25 jobs and format the pipeline data in the way that the stream chart expects.
The resulting stream chart shows the change over time by adjusting the height of each section of the stream based on the number of computers in each location.
Our dashboard will always be pulling the latest data from the jobs that are being run against Active Directory. The dashboard will load quickly because it doesn’t need to aggregate this data itself. Instead, it just pulls the result of the aggregation from the Universal database.
In this post, we went over how to schedule a script with Universal Automation and how to update a dashboard to consume that job output for display in a chart. You can learn more about the features listed in this topic from the links below.