As I had mentioned previously, PowerShell can also be used to view
system health and user activity information.
So to view system health,
the command to do that is Get‑RemoteAccessHealth, and this will give
you a high‑level overview of the system health.
Now you'll see there's a lot of these that don't apply and they show as
Disabled in the HealthState, so you can actually filter out any output
where HealthState is set to Disabled to eliminate some of that noise.
That cleans that up just a little bit.
So anyway,
this information can be used programmatically to determine system health.
You can also use PowerShell to view user activity.
So if we want to look at the remote access connection summary or the
connection statistics summary, the PowerShell command for that is
Get‑RemoteAccessConnectionStatisticsSummary.
And here you'll see this outputs the same information that
we saw in the UI, our TotalConnections, our
TotalUniqueUsers, MaximumConcurrentConnections,
the total amount of data that's been transferred, and so forth.
And, again, this comes from the same data repository, and as I had
mentioned before, when you're looking at this in the UI, all of these
numbers get reset if the service is restarted or if the VPN server is
rebooted, and that same applies here.
So if you're looking at this data,
this is all valuable data since the last time the service
was restarted or the system was rebooted.
We can actually also use PowerShell to look at current sessions, and
that command is Get‑RemoteAccessConnectionStatistics. And here you'll
see all of the current active sessions.
If you'd like to look at what's available to you in each of these sessions,
we'll filter it by an individual user, and here you have all of the
information that's in that individual record that you can report on.
And finally,
you can actually view historical data using the
Get‑RemoteAccessConnectionStatistics command.
You just need to supply a start date and an end date, and it will pull up all of the historical information during that timeframe.