15 May 2022

Snow.NET

Product Release

Snow License Manager has a pretty useful API for pulling information out of the system and doing things with it, but unfortunately the documentation on the API isn’t the best, the example that is provided is how to authenticate and you just need to build out the rest yourself. This isn’t a major issue since if you want to do something with the API, you’ll spend the time working it out until what you’re wanting to do works and has code that if one thing changes breaks for no reason.

I was recently having a conversation with a few people about exporting data from Snow and importing it into a custom CMDB solution that snow doesn’t support via the Snow Integration Manager, which if you don’t know what that is, it basically links up to external systems and pulls the data from things like vSphere and inventories it into Snow, or imports the data into the another system like ServiceNow. The connectors are created by Snow directly and integration outside of that is entirely up to you if you have the time, effort and resource to actually do it.

Snow does have a connector within the Snow Integration Manager called Snow License Manager Data Exporter but it’s pretty limited on what it can pull out and you can add or remove any columns, it’s all or nothing in CSV, XML or JSON only - what if I just want every Microsoft application in XLSX 🤔, for example.

Therefore, I introduce you to Snow.NET, a (kind of) API wrapper that allows you to query any part of the Snow API in a few lines of code and do what you want with the data. It uses RestSharp as it’s client library because why re-invent the wheel, eh?, so authentication and accessing data is super easy. Below is an example of authenticating and getting a list of all Customers the current account has access to.

1
2
3
4
5
6
7
8
9
10
11
12
Authenticate auth = new Authenticate("http://snow.domain.scot/api/", "Administrator", "SnowNET2022!");

if(auth.Client != null) {
    PlatformData platform = new PlatformData(auth.Client);

    Customers customers = platform.Customers();

    for (int i = 0; i < customers.Body.Count; i++)
    {
        Console.WriteLine($"{customers.Body[i].Body.Name} - {customers.Body[i].Body.Id}");
    }
}

Pulling computers with as many or little columns as you want is even easier, for example if you want to export a list of computers on a daily basis automatically via the API that contains the ID, Name, Manufacturer, Operating System, Client Version and Last Scan Date and import it into some custom CMDB solution you can do the below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Authenticate auth = new Authenticate("http://snow.domain.scot/api/", "Administrator", "SnowNET2022!");
int loadedComputers = 0;

private void LoadComputers(int _skipCount = 0) {
    ComputerData cd = new ComputerData(auth.Client);
    Computers computers = cd.Computers(cid: 1, skipCount: _skipCount);

    for (int i = 0; i < computers.Body.Count; i++) {
        Computer computer = cd.Computer(cid: 1, computers.Body[i].Body.Id);

        dataGridComputers.Rows.Add(
            computer.Body.Id,
            computer.Body.Name,
            computer.Body.Manufacturer,
            computer.Body.OperatingSystem,
            computer.Body.ClientVersion,
            computer.Body.LastScanDate
        );

        loadedComputers++;
    }

    if(loadedComputers < computers.Body.Count) {
        LoadComputers(_skipCount: loadedComputers);
    }
}

It also supports filtering, so if you only wanted to pull the above for computers that have Windows 10 Professional installed, you’d simply add in an additional parameter and you’ll only pull back Windows 10 Professional machines and nothing else.

1
2
3
4
private void LoadComputers(int _skipCount = 0) {
    ComputerData cd = new ComputerData(auth.Client);
    Computers computers = cd.Computers(cid: 1, skipCount: _skipCount, additionalParameters: "&$filter=OperatingSystem eq 'Microsoft Windows 10 Pro'");
}

Like everything, it’s Open Source over on GitHub, there’s also an Examples repo to get you started. If it’s not on there already, it’ll also be available via NuGet soon.

//

Song Addiction at he moment: Mars Argo - Angry

Catch. 😊x