Service Bus Scripts

Azure Service Bus is an easy and simple way to get started in the cloud messaging space when you need a highly-reliable cloud messaging service between your applications and services.

I recently had someone ask if there were some simple scripts they could use to get started as they weren’t too interested in the portal for provisioning and wanted to keep things automated in PowerShell until they were ready to go full ARM.

I threw together a few simple scripts to create a Service Bus, Queues, and Namespace Authorization Rules. You can find these and any other new scripts for Service Bus over at my GitHub

Let me know what you think and feel free to submit a pull request!

Epoch To Windows Time Conversion

I recently had a peer reach out and ask if there was a simple way to convert Epoch to Windows time. Being the quick thinker and lover of PowerShell I was I quickly responded with a resounding – YES!

I told him, “Send me an Epoch (Unix) time and I’ll convert it in a jiffy.” and so he did, and thus the best converter in the world was born!!!

Fun fact before we get started:

 On Friday, February 13, 2009 at 23:31:30, the Unix time was 1234567890.

So here’s The Skinny:

$UnixEpochTime = 1484784000000
$Date = Get-Date "1/1/1970"
$UnixTime = $UnixEpochTime / 1000
$date.AddSeconds($UnixTime).ToLocalTime()

In the first line, you can see we hardcoded the Epoch to test a known fixed time
Next, we initialize a date in the format he wants it in.
Then, we divide Epoch time by 1000.
Finally, we take the calculated Epoch and add that time to our local time to get………

Wednesday, January 18, 2017 7:00:00 PM

I’d recommend putting a read-host in there so it can take any input or turn it into a function so you can just make a call to something like a -Time parameter and get the output. You can find the full code here on my GitHub as well.