Pulling Teeth (Reports) – the TeamViewer way

Almost everyone has heard of TeamViewer, and believe it or not there are people that actually use it in business (so they actually pay for licenses and not just use the free edition).

Paying for a license enables you to have management in terms of how the clients (or HOSTS) are configured and reports on which technician is connecting to which machine and for how long. However getting a report from the system actually detailing which machines the software is deployed to, what policy is applied to them, if the online or offline and remote ID…well lets just say that it is not as easy as hitting an export button.

So my one clients had an issue.  They had just had a new TeamViewer (TV from now onwards) version rolled out (that is a a whole other post for another day) into their environment and things were not matching up to their expectations.  They had two different deployment groups on TV and one policy defined for both. Looking on the web portal it seemed that some machines were in the one group and not the other, some were only in the new group and some did not have the policy applied to them.  

Then for good measure, throw in a SCCM report or two, a CMDB report and another deployment tool report and then things start getting REALLY wild in terms of reporting.

Logically it should be no problem pulling a report like that – lets go into TV Console, lets go to the All Devices Group and lets see if there is an export of some sorts?  We needed a report that shows Computer Name, Policy Applied or Not; and this for ALL the deployment Groups in TV.  After clicking ALL over and not finding anything that remotely came to an export function it was time to knock on Google’s door.

One of the posts I stumbled across stated that the information could only be  pulled using a Web API query and a Powershell script – say what?!?!  Looking around the TV site it seems that by doing it this way you could build your own tools and have it run queries against your tenant – great if you are a programmer, not so much if you don’t have coding skills. Here is a link to their documentation regarding this.

The process in the original post above states that you create a token for your site/tenant, and then create a Powershell script that you run and enter this token into it and then magically a file or two should appear on the desktop with your export.   That is in theory.  Here is the code that I copied and pasted into Powershell ISE and SAVED as a .ps1 file (TVDeviceExport2.ps1)  (slightly edited so I could get all the values for Devices and not just a filter of it).  Then ran it in Powershell

$token = Read-Host -Prompt "Enter your API account token now"
$bearer = "Bearer",$token

$header = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$header.Add("authorization", $bearer)

$request = Invoke-RestMethod -Uri "https://webapi.teamviewer.com/api/v1/devices" -Method Get -Headers $header
$request.devices | Export-Csv "$env:userprofile\Desktop\TVDevicesListExport2.csv"

$grequest = Invoke-RestMethod -Uri "https://webapi.teamviewer.com/api/v1/groups" -Method Get -Headers $header
$grequest.groups | Select-Object -Property "name","id" | Export-Csv “$env:userprofile\Desktop\TVGroupsListExport2.csv"

What I got was this error (tip RED is never good):

Invoke-RestMethod : {“error”:”invalid_token”,”error_description”:”Access token is of wrong type. You need a UserToken to call this function.”,”error_code”:2}

Seems that I had created a SITE token instead of a USER token – Doh!

So off to the User Management section of the web portal, found my username then I clicked on the drop down by my name in the top RIGHT and then Edit Profile.  Then click Apps on the left menu, and then Create Script Token button at the bottom of the window.  Here I then selected Read Only / View rights (as I wanted to make sure I did not change anything) and saved it as “User Read Only”.  A unique token was then generated and displayed on the screen – I have obviously blacked this out in the screenshot below.

Using this new USER TOKEN I ran the Powershell script and magically two CSV files appeared on my desktop – TVDevicesListExport2.csv   and    TVGroupsListExport2.csv

TVDevicesListExport2.csv – List of Devices
TVGroupsistExport2.csv – Group Names and ID number

As you can see, the device list has characters and number values for the GroupID and PolicyID.  We have the GroupID so we can use Find and Replace function in Excel and change the GroupID to a legible value, but seems we don’t have the PolicyID values.   Time to refer to the TV API documentation…

After 3 attempts found I could run the following code to pull the Policy information into it’s own file   (TVPolicies2.ps1):

$token = Read-Host -Prompt "Enter your API account token now"
$bearer = "Bearer",$token

$header = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$header.Add("authorization", $bearer)

$request = Invoke-RestMethod -Uri "https://webapi.teamviewer.com/api/v1/teamviewerpolicies" -Method Get -Headers $header
$request.policies | Export-Csv "$env:userprofile\Desktop\TVPoliciesExport2.csv"

The output was exactly what I needed:

TVPoliciesExport2.csv – used to find the PolicyID value

Time to complete the Find and Replace in Excel and then provide the report to the client.

Abandonware – No One Lives Forever

Ever heard of a game called NOLF or The Operative: No One Lives Forever? As part of my big box Sierra games collection, I actually have a sealed box of the game. I haven’t played it, but because it was Sierra labeled it was immediately purchased for the collection.

To quote Wikipedia

A story-driven game set in the 1960s, No One Lives Forever has been critically acclaimed for its stylistic representation of the era in the spirit of many spy films and television series of that decade, as well as for its humor. Players control female protagonist Cate Archer, who works for a secret organization that watches over world peace. In addition to a range of firearms, the game contains several gadgets disguised as ordinary female fashion items.

At the time of its release, many reviewers felt that No One Lives Forever was the best first-person shooter since 1998’s Half-Life. After receiving several Game of the Year awards in the press, a special Game of the Year Edition was released in 2001, which included an additional mission. The Operative: No One Lives Forever was followed by a sequel, No One Lives Forever 2: A Spy in H.A.R.M.’s Way, in 2002, and a spin-off that takes place during the time between the first two games entitled Contract J.A.C.K. released in 2003, both developed by Monolith.

No One Lives Forever Big Box

Well in my Google feed the other day an interesting article popped up about the history of the game and how it is currently in limbo between the different owners, and how the gaming community tried to get the rights to it but pretty much hit a brick wall. 

Well deciding not to leave it there, the gaming community has tweaked the game to run on modern computers and operating systems (Windows 10) – they even patched it to run in UHD!  Have a read here what I think is a very interesting article.

Tweaked NOLF Game Play

Well the good news is that you don’t have to Google to find the tweaked abandonware NOLF 1 and 2 – here is the link:  http://nolfrevival.tk/

To quote the site:

The Revival is Here
Download a fully functional version of No One Lives Forever (NOLF), No One Lives Forever 2 (NOLF 2), and Contract Jack with the latest community patches for free. Download the full game for PC now. Play single-player and multiplayer NOLF games for free! You cannot buy a functional version of No One Lives Forever or Contract Jack any more. As a result, in an attempt to keep the community alive and attract new players, No One Lives Forever and Contract Jack Revival Edition are available to all for free and are a breeze to install and play on all modern operating systems. Double click on the installer, pick a directory to extract the files, and then double click on the desktop shortcuts to play. It’s that easy.

Time To… Hibernate

I have found now that on a number of occasions that I cannot power my machine off when I wanted to as it is still running a script or something, but I also don’t just want to leave it on just because I cannot sit and wait for it to finish. 

Ever experience something similar?  I also didn’t want to just download another application just to hibernate my machine on a schedule so I decided to look if there was a more “old-school” command line method that I could use that may be able to do it for me…

After some searching I found a post over at howto-connect.com that used the command TIMEOUT at the command line. It uses the number of seconds to wait until the command is run.

timeout /t xx /NOBREAK > NUL && shutdown /h

So running the above command and replacing the xx with 60 (for 1 minute) or 1500 (for 25 minutes) will let the computer “wait” for that period of time before running the command to the RIGHT of the && – so in the above example: shutdown /h

Now all that is good and well, but having to try and work out how many seconds 48 minutes is requires a calculator for me. So I got to thinking… what if I could create a batchfile that would prompt me how many minutes I wanted to wait for, then automatically multiplied it by 60 and then put that result in as the value in the timeout section of the command…

Step #1 would have to be to set a variable called minutes. This would be for the user to type in how many minutes to wait for.

set /p minutes=Enter Minutes To Wait: 

OK now to take that %minutes% variable and multiply it by 60 (seconds).  After looking around I found an interesting article by Rob van der Woude about doing calculations at the command line. In this case a new variable would be created called Result, this from taking the %minutes% and multiplying it by 60. The command I was looking for was:

set /a Result = %minutes% * 60

And then finally to use the %Result% variable in the timeout command:

timeout /t %Result% /NOBREAK > NUL && shutdown /h

So finally we had all the bits of the code, time now to create a batchfile and bring it all together. I decided to name the file HIBERNATE.CMD Here is the contents of the batchfile:

@echo off
set /p minutes=Enter Minutes To Wait: 
echo.
echo Counting down the time...  Please Wait...
set /a Result = %minutes% * 60
timeout /t %Result% /NOBREAK > NUL && shutdown /h

I am pleased to say that although not a pretty GUI or any fancy bells or whistles, it works like a charm for me! Till next time…

What? PowerPoint 95 no longer supported?

So I had an interesting request come past me the other day.  A client had very old (as in created in 1995 and last printed or saved in 1998) PowerPoint files that he wanted to open…however Office 365 was not interested in opening it at all.

When attempting to open the file, PowerPoint 365 would throw up an error stating that “PowerPoint can’t read <filename.ppt> because the PowerPoint 95 file format is no longer supported”  Seriously Microsoft?!?  So much for backward support

The Error Message

After Googling a bit it seemed that Microsoft had a valid reason for it – it was no longer a “safe” format, so they canned support for it…anyway back to the request. There is an online service that one can upload these files to that will do it for free however there is a limit to the number of conversions done a day and I am not to comfortable uploading potentially sensitive (even though it is old) files to a server that I don’t know what will happen to it. There had to be a better solution…

I found a post somewhere that said that OpenOffice / LibreOffice used to be able to open the older formats….hmmmm…maybe if it could open it then it could save it as as newer format then also… So I went off to the LibreOffice website looking for a “portable” version of the app. Now for those of you who do not know what a “portable” version means, it means a version that you can download and run without having to install the application to your machine. Found the page and downloaded it – link here. It was a 160Mb download that I extracted to my C:\TEMP folder.

Running the application for the first time takes a while for it open and set itself up in the temporary environment, but once up and running it worked like a charm. I opened LibreOffice Impress (the equivalent program of PowerPoint) and then attempted to open the file…this is what I was greeted with:

Woohoo! It works!!!

OK so at least we could open it, now to try save it as something newer that Office 365 PowerPoint could open. File, Save As, File Type… Wow we have some formats to choose from!

Different file formats to choose from

Great! Now to find out if we can somehow convert files in bulk instead of doing the whole File, Save As process. I then stumbled upon another site where the members discussed how to have OpenOffice \ LibreOffice open up without showing a window (GUI) and then convert from a specific format to another AUTOMATICALLY!

So under my C:\TEMP folder I had the Portable LibreOffice version in its folder (C:\TEMP\LibreOfficePortable). I created another folder called PPT (C:\TEMP\PPT) where I placed the PowerPoint 95 test file (and made multiple copies of it to simulate a bulk conversion), and another folder below that PPTX (C:\TEMP\PPT\PPTX) where the converted files would go.

I then created a batchfile (convert2pptx.bat) that had the following in it:

for %%f in (*.ppt) do (
C:\temp\LibreOfficePortable\App\libreoffice\program\soffice.exe --headless --convert-to pptx --outdir "C:\temp\PPT\PPTX" "%%f"
)

To to breakdown what the above was doing:
1. In the current folder, any file that ends with .ppt, do the following
2. Run the soffice.exe file
2.1 as “headless” (so don’t open up and show the GUI)
2.2 convert the format to PPTX format
2.3 use the following folder as the output folder
2.4 keep the existing filename when saving it as PPTX

The script in action and the output files

Finally a solution for the client to bulk convert all his PowerPoint 95 files to a compatible version that PowerPoint 365 could open.

Pretty impressed (and thankful) that LibreOffice could do that…

I’m back … after a LONG absence …

From the Eish! DepartmentThe saying goes that you get so busy that you don’t know if you are coming or going and that is so true!

You may have noticed that my last blog post was in May 2014, when I posted about my LCHF diet and what I was eating for breakfast at that time…ah the good old days…

I was based at the Pretoria office at the firm that I was working at and slowly but surely more and more work was piled onto my plate and eventually I was asked to help out at the Johannesburg office with a major project.   From there, I am sad to say, I started to slip up on my diet … the commute and long working hours meant that I had less time to go for the morning walk, and less time to prepare my meals or go to the canteen to eat breakfast the way I should have.

My blog (this one) , which I do purely for personal enjoyment – contrary to the hundreds of spam saying I should monetize it – started falling behind and sadly I was no longer paying attention to it…

I really did not know if I was coming or if I was going anymore – until now.

In the coming months and weeks I will be start posting again about the adventures I was on during this absence. There are a lot of changes that is happening now in my life and I will share as I go along, but for now know that I am back as best as I can be and hope to keep pushing out the posts in a more regular manner.

Thank you for your patience during my absence – regards  MadMike

PS: for those who posted comments

  1. The Nexa phones sadly I called all over without success and the batteries, screens and spares are about as scarce as hens teeth. I approved a comment by who seems to be one of the vendors where he listed his number, not sure if he can still help.
  2. Regarding the D5 Evo gate motor – if you are in the Gauteng area a gent by the name of Mark used to do security at my previous company he can assist with repairs (011 485-1434), alternatively if you are in Pretoria you can buy replacement controller boards, batteries, remotes etc directly from  Centurion Gate Motors (Address: c17, 2 Meiring Naude Road, Scientia 627-Jr, Pretoria).  They also offer a swop out service on the controller board (an upcoming post for that).
  3. To the gentleman who was very angry about me rating yogurt and calling it a food and how dare I – sorry I still like certain yogurts more than others and it is a food 🙂

 

LCHF – What do I eat? Breakfasts (Part 2)

Topic - LCHF

In my previous post about “What do I eat for Breakfast” I gave 2 examples of what I would typically eat at the office for breakfast.

As promised I took a few more photos so you can see what else I eat for breakfast.  Remember only eat if you are hungry.

Example #3:

LCHF-Breakfast-Ex4

2x Eggs, 2x Beef Sausages, Mushrooms

  • 2x Eggs
  • 2x Beef Sausages
  • Fried Mushrooms and Onions and Green Pepper

Lasted: 5+ hours    (ate at about 08h00 and had Lunch just after 13h00)

Example #4:

Scrambled Egg, Beef Sausage, Chicken Livers

Scrambled Egg, Beef Sausage, Chicken Livers

  • Scrambled Eggs
  • 1x Beef Sausage
  • Chicken Livers

Lasted: 5+ hours    (ate just after 08h00 and had Lunch just before 14h00)

Example #5:

Montagu-Mixed_Nuts

Mixed Nuts

Lancewood Full

Lancewood High Fat Double Cream Yoghurt

  • Bowl of Double Cream Yoghurt (Lancewood of course 🙂 )
  • Handful of Mixed Nuts (unsalted) (we found Montagu quality/price best for us)

Lasted:  7+ Hours!  This was amazing!  I ate this just after 08h00 in the morning and when I looked again it was 15h45!

In closing I hope this gives you some idea that living this lifestyle is actually quite tasty!  Updates on Lunch and Supper coming up!