PowerShell: Measuring Download Speeds

Have you ever downloaded a file from the Internet? Probably.

Have you ever downloaded a file with PowerShell? Maybe.

Have you ever wondered how fast your download was going? Sure.

Have you ever wondered how to get that information when you’re downloading a file with PowerShell? Maybe, but you didn’t have a solution until now!

Our web browsers calculate download speeds for us, somehow. Specifically how, I have no clue, but what I do know is that we are more than capable of calculating download speeds using PowerShell.

Read morePowerShell: Measuring Download Speeds

PowerShell: Embed binary data in your script

When writing automation scripts or modules, you might find that you frequently reference external binary data.

Binary data? Well, that accounts for all data!” you might say.

Yes, that’s true. But I’m talking about binary data as opposed to files containing simple ASCII or UTF-8 data. Maybe there’s some better terminology to describe that, but hey it works for now. Binary data could include things such as:

  • Word documents
  • Executable (Portable Executable format)
  • Code libraries (DLLs)
  • Registry files
  • etc.

In the case of executables, oftentimes they provide useful functionality that would take many lines of PowerShell code to replicate. Some developers, for better or for worse, elect to use these utilities instead of going through the effort of writing the necessary code to handle the function natively in PowerShell. This creates an additional dependency when porting the PowerShell code, as the author must be sure to include the utility with their code, or otherwise ensure (via documentation, for example) that the target user will already have it available.

Wouldn’t it be nice if you didn’t have to depend on the user having some executable pre-installed, just to get your script to work, though? Unfortunately the little topic of “software licensing” can sometimes prevent redistribution of software that you are not given explicit permission to copy, however there are also many cases where this is allowed (eg. open-source projects). The work-around in cases where redistribution is not allowed, is to either direct the user where to download the software from, or automate it for them.

Read morePowerShell: Embed binary data in your script

PowerShell: Tracert or Trace-Route?

UPDATE (2012-07-27): Justin Dearing (@zippy1981) sent me an updated version of the script, which improves on the following:

  • Has some comment-based help
  • Parameter checking

Grab it here: Invoke-TraceRoute.ps1


Any network or systems administrator is familiar with the good old tracert.exe utility that’s been included outof-the-box in Windows for years now. Tracert allows you to identify each “hop” (typically a router) between two IP endpoints on a network. Since this utility was developed long before PowerShell existed, and has been time-tested, it hasn’t been implemented yet as a PowerShell cmdlet. That being said, PowerShell folks often do not enjoy reliance on external dependencies, and prefer the flexibility of an API that can provide only the information that they want or need. To that end, I have developed a Trace-Route PowerShell advanced function (cmdlet) that emulates a limited set of functionality offered by tracert.exe.

Read morePowerShell: Tracert or Trace-Route?

PowerShell ISE v3: Keyboard Shortcut to Close Script Tab

Background

In the PowerShell Integrated Scripting Editor (ISE) v3, the common [Ctrl] + W keyboard shortcut is mapped to the “Close PowerShell Tab” action. Personally, I would like to see different behavior, whereby that shortcut is used to close the active script tab until there are none left, at which point it may then close the active PowerShell tab. Unfortunately that’s not how it works, and it probably won’t get changed for the final release of PowerShell v3. Either way, I did file a bug report for this issue on Microsoft Connect.

There is, in fact, a keyboard shortcut mapped to the “Close Script Tab” action, however it’s a keyboard shortcut that I’m personally not very fond of. The [Ctrl] + [F4] shortcut is rather convoluted, and although it may have a legacy in the Microsoft world, I find it to be very uncomfortable.

Read morePowerShell ISE v3: Keyboard Shortcut to Close Script Tab

Introducing Microsoft’s OFFICIAL Windows Azure PowerShell Module!

Hello folks! Today, Microsoft has officially announced the availability of a new PowerShell module to help manage Windows Azure features! In order to obtain this module, you will need to download the Web Platform Installer 4.0 (x64, x86). Once you’ve installed the Web Platform Installer 4.0, you’ll need to search for “PowerShell” and install the “Windows Azure PowerShell” package from it.

Read moreIntroducing Microsoft’s OFFICIAL Windows Azure PowerShell Module!

PowerShell v3 RC Bug: $MyInvocation.MyCommand.Path is $null in supporting script module files

In PowerShell version 2.0, you could use the $MyInvocation.MyCommand.Path property to detect where a script block was being called from. This was very useful to me, because I would embed test code in the bottom of each of my supporting script files, for a given module.

Read morePowerShell v3 RC Bug: $MyInvocation.MyCommand.Path is $null in supporting script module files

PowerShell 3 RC: New Send-MailMessage Parameter for Port Number!

Did you know that in previous versions of Windows PowerShell, there was no built-in way to specify a custom port to send an e-mail to a SMTP server? It’s true, Microsoft did not include that parameter until the release candidate (aka. release preview) version of PowerShell version 3.0. The release candidate of Windows Management Framework … Read morePowerShell 3 RC: New Send-MailMessage Parameter for Port Number!

PowerShell: Getting an access token from Instagram (oAuth 2.0)

So I’ve recently been struggling with the first step of oAuth 1.0a, which is getting a “request token.” Twitter still uses oAuth 1.0a, and although they have fairly decent documentation on the authentication flow, I’m still having a rough time with it. I had read that supposedly oAuth 2.0 would be easier to work with than oAuth 1.0a, but that didn’t really matter to me since Twitter isn’t using oAuth 2.0 yet.

When push came to shove, and oAuth 1.0a was still giving me headaches, I figured I would just try out oAuth 2.0, to see how easy it was to get an access token. As it turns out, it’s REALLY FREAKIN’ easy, and you don’t have to worry about giving out your application’s consumer secret key (aka. consumer key, client secret, etc.), which is sensitive information. Rather, all you need to do is pass in your callback URL (the one that you configure on your application registration), and the consumer ID (aka. client ID) that the service provides you with.

Read morePowerShell: Getting an access token from Instagram (oAuth 2.0)

PowerShell: Get the Windows Azure Certificate

Microsoft Windows Azure Logo

If you’re automating Windows Azure using Windows PowerShell, one of the first things you’ll probably notice is that you need a management certificate to connect to the Windows Azure subscription that you’re attempting to view or modify. Management certificates are associated to a Windows Azure subscription inside the Management Portal, under the Hosted Services, Storage Accounts … Read morePowerShell: Get the Windows Azure Certificate

PowerShell Saturday Presentation Slides

On Saturday, March 10th, 2012, the first ever #PowerShell Saturday event took place in Columbus, Ohio. The main folks involved in organizing this event were: Wes Stahler Ed Wilson Teresa Wilson First off, a massive thank you and respect to the organizers for bringing about such a successful event! There were two session tracks going … Read morePowerShell Saturday Presentation Slides