Once Inbox Accounting has been enabled,
it's really crucial that we perform some maintenance tasks right off the bat.
To begin, we need to run the command, Optimize‑InboxAccountingDatabase.
Running this command simply makes a change to the database that is helpful for,
usually for busier deployments,
but I like to do this on all deployments just for good measure.
Essentially, the Inbox Accounting database,
as I'd mentioned before, is a SQL database.
It's actually missing a crucial index on one of the tables that can
cause performance issues and memory‑consumption issues,
and also high CPU‑utilization issues.
This command, Optimize‑InboxAccountingDatabase,
adds that index back to that table,
and then you won't have this problem in the future.
By the way,
this affects, all versions of Windows all the way back to Windows Server 2012,
all the way through Windows Server 2022,
this is still a problem, and so if you're going to enable Inbox Accounting,
I would strongly encourage you to run this command so that
you don't have those challenges and issues.
So a couple of other commands that I want to point out,
you can actually view the size of the database by
running Get‑InboxAccountingDatabaseSize,
and here, you'll see that the default is about 12+MB.
Now, again, this database contains no data,
but you'll notice that if I run the Compress‑InboxAccountingDatabase command,
immediately, I recover nearly 10MB, 9MB of data here.
So you can see that this database is terribly inefficient.
This command, I would encourage you to run on a regular basis,
probably run it as a scheduled task.
That way,
you know that your database is always consuming the
least amount of disk space possible.
The next command I want to demonstrate is actually backing up the database.
So we want to do this periodically as well because if we lose a server,
we don't want to lose this valuable user activity
data that we've been recording.
The command to do that is just simply
Backup‑InboxAccountingDatabase. And when you run this command by default,
it just places it in the default folder of C:\Windows\DirectAccess\db\.
And there, you see our file backup.
Also to better demonstrate reporting,
I'm going to import a database that has more user data in it.
So we'll run the command, Restore‑InboxAccountingDatabase,
and we'll specify the backup file.
And then once that's complete,
I should be able to generate a report for historical data.
So I'm going to set my start date to something a little bit older.
Let's go back to February or so.
Let's see who was accessing for the month of February.
So I'll choose that and the 28, so from the 1st to the 28th.
We'll click Generate, and here,
you'll see I have all kinds of data in this database.
Now, this is my lab so it's not really exciting.
There are only one or two different users in here, but you get the idea.
I can go back and look at a connection and see historical data,
so what was the user accessing, who was the user,
and various information.
And once again, much like I demonstrated in the previous lesson,
you can add and remove columns here.
So you can always regain some space by taking some columns that
you don't need and adding more important information for
columns that you do want to display.
One of the things that I like about this as well is
that you can also do a search, and the search is actually on the reported data.
So I've generated a report for this month of February,
and I want to see all the users who are Rick Deckard here,
and so then I can hit Enter and see all of the
sessions that this user had generated.
And again, I can see detailed information down here in the lower panes,
or I can double‑click on a connection and gather this information as well.
So as you saw,
the default location for the DirectAccess database is in on the C:\ drive,
so that's probably okay for smaller deployments,
but if you're expecting a lot of concurrent connections,
a lot of sessions, and you want to store data for extended periods of time,
perhaps having the database on the C:\ drive is less than ideal.
Now, as I'd mentioned before, we can relocate the database using my tools,
but it is not formally supported by Microsoft so once again use caution here.
Now, what I'm going to do is just run the command, Move‑InboxAccountingDatabase.
The source path does not have to be specified because by default,
it will find the original files in the original location.
So if this is the first time you're moving it,
it's going to be in the default location,
so you don't need ‑SourcePath, but you do have to specify a destination path.
And in this case,
I'm going to put it on the D:\ drive, and I'm going to use the
same folder structure as we use on the C:\ drive.
Once that's done,
my database has been moved to the D volume, and of course, now I'm going to
have better performance and obviously have much more disk space so that I can increase my storage times if I need to do that.