Intune: Automatically set timezone on new device build

In Michael Niehaus’ recent blog on Configuring Windows 10 defaults via Windows Autopilot using an MSI he talked about the ability to set the Time Zone of the device based on a variable in the Config.xml file. One of the comments on the blog asked whether it would be possible to set the time zone based on where the device was at the time of setup rather than based on an attribute in the file.

Whilst Windows 10 has a feature to detect the time zone automatically I have found on occasion with devices that this doesn’t always work out of the box and the time zone remains in a region that is not accurate for where the device is. This should be relatively simple to automate if we can geo-locate the public IP address and match those coordinates to a valid time zone. For this I am using two web services:

  1. – this will map the public IP address to a geo-location including coordinates, you get access to 10,000 queries a month for free
  2. Bing Maps API – this will return the correct time zone in a valid Windows format that can be used in the script to set the time zone on the device, there is a free tier here that also gives you 10,000 queries per month without charge

The Script

The script will execute the following in sequence:

  1. Attempt to get the coordinates of the IP address you are using via the IPStack API
  2. If successful, attempt to find the time zone from the Bing Maps API
  3. Compare the value of the current time zone on the machine with the response from the Bing Maps API
  4. Change the time zone on the machine

The only variable you should need to change in the script are the two lines that will contain your API keys helpfully called ipStackAPIKey and bingMapsAPIKey.

You can choose now to either save the file as a script to run once in Intune, or, incorporate this into Michael’s MSI. If you wanted the script to run every time the machine starts up, you could adapt the Logon script from my recent post on Mapping legacy files shares for Azure AD joined devices.

The script will output to a folder in %PROGRAMDATA% called Intune-PowerShell-Logs.

Hopefully you will find this useful to configure time zone information on your Modern Workplace machines.

Reporting on inactive AD user accounts

In the second quick article following my reporting requirement this time is to report on the enabled user accounts that have not logged in in the past X days. Again a quick Google came across the following article on WindowsITPro (Use Get-ADUser to Find Inactive AD Users)

I took the Search-ADAccount cmdlet and created some filters to exclude disabled accounts as well as enable a parameter to be passed with the script to specify the maximum age, in days, of a user account (default is 90 days)

Save the below script as Get-InactiveAccounts.ps1

To execute the script run .\Get-InactiveAccounts.ps1 to report on accounts older than 90 days or use the InactiveDays parameter to specify the age of accounts to report (eg .\Get-InactiveAccounts.ps1 -InactiveDays 180)

Reporting on AD users last password change

As part of some recent work to assist a client with reporting on their active users and the dates those users last changed their passwords I evolved a script written by Carl Gray here (PowerShell: Get-ADUser to retrieve password last set and expiry information) to generate a short PowerShell script that will report the enabled Active Directory users and the date that they last set their password.

Copy the code below and save on your server as Get-PasswordLastChange.ps1 and then run from the command line. Script will produce a CSV file and save it in the same directory as the script

27 inspiring top notch programming quotes

This is a brilliant post that I stumbled across this morning. My favourite two quotes are:

If debugging is the process of removing software bugs, then programming must be the process of putting them in. – Edsger Dijkstra


Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. – Brian Kernighan

read more | digg story

Install Vista without a CD key

Daniel Petri comes up with another great tip and insight into the way Microsoft’s software can be manipulated to do things you want to do. In this case how to trial different versions of Windows Vista. Once the activation deadline is reached you must put your legal key in for the version you installed to continue but… it does let you try the different versions first!

read more | digg story

Microsoft amused by the iPhone – and rightly so

Having seen and commented on the iPhone earlier this week I am happy to see that Microsoft have come back and agreed with my opinions that they have already got a number of devices that can do this and don’t cost an absolute fortune to buy.

I also loved the comment from Steve

“£500 dollars…. that’s the most expensive phone in the world and it doesn’t appeal to business customers because it doesn’t have a keyboard”

Great comeback.

Source [ Gizmodo ]

Apple iPhone…. My 3100 does most of that already

Well Apple have certainly done it again. The iPhone looks awesome and it really is a nice design and innovative solution to combining everything into one portable device. But I already have all I need.

My M3100 (HTC Hermes) has a powerful computer, it can do all my emails. POP, IMAP, Exchange – iPhone wont support this, i can take photos on it and view them as a slideshow, I can browse the Internet using 3G and even listen to my music on it. Granted I wont have anything as powerful as iTunes to play my music but to be honest if I wanted to listen to music i will use my iPod.
I would like to see if when rotated the other way, to shown in the video below, that the screen rotates like that as well – otherwise that’s a bit poo really! My screen will rotate and it also has a built in full QWERTY keyboard that will let me type messages to my hearts content.

I can look at all my contacts I can do everything I would want to do on my phone and some more.

Apple your phone is very pretty and I’m sure that it will sell really well but at the cost it is I cant see how I can afford to do it. My Hermes will keep me going for a year or two and by that time there will be something else that is newer and more cool and cheaper!

It’s been a long time

Well it’s been over a month since I last wrote something here (not including the facebook bit I just published) and that’s mainly been due to the fact I now have a job and am incredibly busy.

I now work for Wavex where I am a Service Desk Engineer. Since starting there I have been incredibly busy and just not found the time to actually write anything here. My day starts at 6:45 am when my alarm goes off and I am out of the door 30 minutes later. I get the 0724 train from Leatherhead up to Waterloo and spend most of that time trying to complete the Solitaire game on my phone. Initially I got the tube but found that the Central line is possibly the most painful 5 minutes of my life each day so I have started walking from Waterloo to Holborn which makes the journey much more interesting and actually takes about the same time. My day doesn’t end in London until 6 and then by the time I am hope it’s normally around 7:30 and I just don’t want to have to worry about using a computer again until the next day.

Work is great fun and the office is incredibly relaxed – Jeans and T-shirt beats a suit any day. I find the work challenging and also incredibly rewarding as you never know who is going to phone you up next. Hopefully this is going to be something that I can develop and start to understand and learn more about IT.

I must admit that when I got the call from the HR manager at work saying that he had read this Blog I was slightly worried that the content may have been slightly random and odd for potential employers to be reading but having been at Wavex for a month and a bit now I can see that the sort of things here fit in with the way the company works!

Positive Job News

I haven’t been around for a while to write something new here and as this is now the end of my last week of post student – pre work time I thought I would add something new!

For those of you who don’t know I now have a job at a nice company in London called Wavex. Wavex are a company who support other clients hardware and software, ensuring they keep a maximum uptime. My role within the company is to work as a “Service Desk Engineer” answering calls as and when they come in. Everyone in the office seems very nice and I am looking forward to starting work there. The only downside is, in some people’s eyes, that I have to commute every day into London. This doesn’t bother me and I quite enjoy the hour I get to sit and read the paper whilst listening to my tunes as I sit on the train.

All this positive news is good and is a relief to both myself and my parents for differing reasons. I spent a long time applying for jobs through the Reed and Monster websites but nothing came of them. The one interview I had was with a company in reigate who sent me a very blunt “you didn’t get the job” letter with no reasons why after what I had believed to be a positive interview – Oh well, their loss! I also didn’t want to have to spend a year or so working in an admin role and then hope to move through a company into IT which is what a Dorking based recruitment agency said. This same agency managed to arrange an interview for me earning significantly less than I am going to be earning but failed to send me the correct information so I was unable to turn up. Well done guys!

Right – that’s enough for now. I will find more useful/interesting things on the internet soon and post them here for you all to see!