PowerShell: Updating an Azure Service Display Name

If you’re like me, you probably like clarity, consistency, and conciseness. Given that, I like to ensure that names of hosted services in Windows Azure are named appropriately. Sometimes developers will give a service a quick name that they understand, but may not relay enough information to other team members, at a glance, as to … Read morePowerShell: Updating an Azure Service Display Name

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

PowerShell: Automate Windows Azure Service Bus queue creation

Microsoft Windows Azure Logo

One of the core services provided by the Windows Azure “cloud computing” platform is the ability to create first-in, first-out messaging queues. These queues are considered to be part of the Service Bus feature in Windows Azure. In some cases, it may be desirable to automate the creation of these queues, especially if there are a lot of them to create. By automating this process, rather than performing it manually, you can ensure consistency, repeatability, and speed.

Starting out with Windows Azure automation might lead you to download the official Microsoft Windows Azure cmdlets, or even the third-party Cerebrata Windows Azure module for Windows PowerShell. The latter module appears to have cmdlets that support queue creation, however the former (Microsoft) module does not. If you’d rather not spend the money on the Cerebrata module, can’t get your company to buy it for you, or you’d rather just stick to native Microsoft stuff, you’re still in luck. The Windows Azure .NET SDK 1.6 allows C# developers, and PowerShell script writers, to create queues using the provided .NET types!

Read morePowerShell: Automate Windows Azure Service Bus queue creation

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: Twitter Folks

Hey folks, here are some of the top tweeters on the topic of PowerShell! All of them come with my strong recommendation to follow them! You will be in good company, and will probably learn a LOT, if you keep in touch with these ridiculously smart folks.

Jeffrey Snover – https://twitter.com/jsnover

Don Jones – https://twitter.com/concentrateddon

Jon Walz – https://twitter.com/jonwalz

Hal Rottenbeg – https://twitter.com/halr9000

Doug Finke – https://twitter.com/dfinke

Boe Prox – https://twitter.com/proxb

Adam Driscoll – https://twitter.com/adamdriscoll

Ravikanth Chaganti – https://twitter.com/ravikanth

Read morePowerShell: Twitter Folks

PowerShell: Backup documents on Dropbox securely with encryption

Like many other people out there, you’re probably looking for a way to backup your documents regularly, reliably, and securely on some sort of central storage service. Dropbox is a great option for this, since they provide a fair amount of storage for free, and their annual cost for additional storage is pretty fair. Unfortunately, … Read morePowerShell: Backup documents on Dropbox securely with encryption

Copy Filenames to Clipboard with PowerShell

Have you ever wanted to copy a large amount of data to the Windows clipboard, but haven’t known quite how to do it? How about this scenario: you have a folder full of files, and you want to get a list of the files’ full names / paths. That’s pretty easy to do with a … Read moreCopy Filenames to Clipboard with PowerShell

PowerShell: Prompt Function to Monitor Memory Usage

Have you ever wanted to monitor your memory utilization in a PowerShell instance, but may not want to continually issue commands to determine it? Introducing …… the PowerShell Prompt to monitor memory utilization!! function prompt { "$(‘{0:n2}’ -f ([double](Get-Process -Id $pid).WorkingSet/1MB)) MB> " } Here’s the result: