Installing OMS and Service Map Agents with PowerShell

Back in January this year I wrote a post about how you can install the OMS agent using PowerShell. Now the time has come to include the Service Map agent in the equation as well since this is a feature that recently got Generally Available. You can find the original post about installing the OMS agent here. What´s new in this script is that I have added a section for downloading and installing the Service Map agent as well. Enough talking, let´s get to it!


You will of course need the script, which you can download from my TechNet Gallery here. Download it and place is somewhere where you will find it the next time you want to use it. 😊

See the script below;

Alright, so the script is in place. Lets´s rock and roll!

Before you can run the script you´re going to need two things.

  1. Your Workspace ID
  2. Your Workspace Primary Key

Head over to the OMS portal and step into Settings -> Connected Sources -> Windows Servers. Copy the Workspace ID and the Primary Key as seen below.

Running the script
You need to run the script as an administrator, and you will also need internet access from the server to download the files. However, if you don´t have internet access you could always download the agents somewhere else and copy it to the folder C:\Source and the agent would be installed by the script.

See below what it looks like running the script. You will be asked to put in the Workspace ID and the Workspace Key that you just looked up.

The agents are downloaded to the folder.

And you´re done installing the agents. You´re ready to go Service Mapping. 😊

Just to show you what it looks like, the two agents are installed and good to go.

This query will show you all the Windows servers (and clients for that matter) that are communicating with Log Analytics. As you can see, the TBGW01 server are also communicating now that the agents are installed.

The query to use: Type=Heartbeat OSType=Windows | top 500000 | dedup SourceComputerId | Sort Computer | display Table

Looking at the Service Map solution in the OMS portal will show you something like below.

And then you will have your server assesses using the Service Map agent as you can see below.

I hope this will help you out in installing OMS and Service Map agents in your environment. I have deactivated the section in the script that deletes the C:\Source folder when the installation is done. This is simply because you shouldn´t delete the folder if you have any other important files in there. Feel free to use the line if you want to, but you will need to activate it yourself by editing the script and removing the lines 83 and 94.

If you want to know more about Service Map, you can check out my previous posts, A first look at OMS Service Map and A deeper look at OMS Service Map.

If there are any questions, just leave a comment below and I´ll get back as soon as possible. Otherwise, have fun deploying agents in your environment 😊

Leave a Reply

Your email address will not be published. Required fields are marked *