Welcome to this addition of the PowerShell ABC's where you'll find 26 posts detailing a component of the PowerShell scripting language, one letter at a time. Today's letter is the letter "Q" and there wasn't really much to go with. We've got the "-Quiet" switch but that's fairly limited in it's usage. I opted for it's support for the FIFO data structure: queues.
A queue is a particular kind of collection in which the entities in the collection are kept in order. Operation on a queue are to add items to the end position and remove them from the front position.
As a First-In-First-Out (FIFO) data structure, the first element added to the queue will be the first one to be removed.
There are many types of Queues that you can work with, including native .NET Queues, Windows Azure Queues, and IBM WebSphere MQs.
PowerShell doesn't have a native queue data type but that doesn't stop you from being able to build and manage one as the .NET framework has done that for us and since PowerShell has access to all of the .NET Framework classes, working with a queue is as easy as calling the New-Object Cmdlet on a System.Collections.Queue object.
PS C:\> $q = New-Object System.Collections.Queue PS C:\> $q.Enqueue("one") PS C:\> $q.Enqueue("two") PS C:\> $q.Enqueue("three") PS C:\> $q one two three PS C:\> $q.Dequeue() one PS C:\> $q two three PS C:\> $q.Enqueue("four") PS C:\> $q two three four
Windows Azure Queues
Let's not stop with local queues, PowerShell allows you to access them in the cloud as well. Windows Azure is the foundation of Microsoft's Cloud Platform and provides the building blocks for application developers to write scalable and highly available services. One of those building blocks is the Windows Azure Queue which provides a reliable message delivery mechanism. Microsoft has provided a "CloudDrive" sample that implements a PowerShell Provider to to enable command line access to Queue Storage resources.