Skip to content →

Configuring your Personal NMAgent Session Store

OrganizingSessionsToday I would like to explain a little bit what Session Stores are for the NMAgent and, therefore, what a Personal Session Store is. A Session Store is a database table that holds the information from your Agent Sessions when you have tell him to do so. Every run command invocation fires a new Agent Session and you have the option to persist the results in a database if you issue the -save parameter as well on the CLI.

Since version 4.54b0 you can choose your Session Store and define its name on your Profile Settings. Consequently, you will notice that several new parameters are present in all your settings-<ProfileName>.ps1 files. These are:

These parameters become useful when you share your Session Database with one or more IT Teams. It is also handy when you schedule NMAgent sessions for regular execution and want to distinguish the automated sessions from your interactive ones.

The default Session Store is _SessionStore and this is the reason why all the predefined Profile Settings refer to it. In fact, if you enter the shell mode, you can see by yourself how it looks like:

As you may have guessed, the columns AgentUserId and AgentUserName directly map the contents of $AgentUserId and $AgentUserName respectively.

Ok, after this brief introduction, you just probably understand that, to define a different Session Store in your Profile Settings, it must previously exist. The question, is, then, how do we create new Session Stores? The answer is simple: the archive command.

To use the archive command you need you have an existing Session already stored. If that’s not the case, just set up a new session and run it with the –save parameter. This are the basic steps to do achieve it:

  1. Go to one the library (i.e: .\modules\openslim), choose one or more modules, copy and paste it/them on its _enabled folder (i.e: .\modules\openslim\_enabled).
  2. Choose a Target Computer and run an NMAgent session against it.
  3. Clean the _enabled folder after the execution (if you are not going to use them again…).

Following our example, this would be the command we should issue from the CLI:

If you already have some session information stored in the default Session Store, you can start by verifying that, in fact, that’s the case:

Now, we are ready to archive this data into a new off-line Session Store:

and verify that your new Session Store has been created correctly…

… and that your information has also been archived:

That’s it. Now you are ready to change the value for $AgentUserSessionStore in your profile settings files so that you can use the new Session Store as your primary Session Store. It is important to do it in all your settings-<ProfileName>.ps1 files.

In any case, you should remember that settings-main.ps1 is the most important one as is the one that is use as the default profile.

You can make a quick test to see that everything is working fine:

Naturally, you can always access the old Session Store or any other one that shares the same NMAgent Session Database:

Why this matters

Now that you know how to organize your NMAgent Session Database you are ready to apply whatever criteria fits to your needs. As noted before, there are two big database sharing scenarios that make this feature useful:

  1. organize the activity of one or more IT Teams.
  2. isolate the activity or your automated/scheduled NMAgent sessions: baselining, auditing, etc.

Anyway, you can always share the same Session Store and use any of the available columns to filter the information you need. For example, remember that:

  • the value of the AgentUserName column gets populated with the contents of $AgentUserName.
  • the value of the AgentNodeName column gets populated with machine name where NMAgent has been executed.

This would be an example from the later strategy:

As usual, I wish this information has been useful to explore the secrets hidden among your systems and infrastructures ;-). Have fun!

Configuring your Personal NMAgent Session Store by Carlos Veira Lorenzo is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Published in Automation Projects System Management