Decorating PowerShell Objects

Ever wonder how PowerShell seems to know how to format objects? When you run Get-ChildItem or Get-WmiObject, you only see a few key properties, but a wealth of other information is available through commands like Select-Object and Get-Member. Have you ever written a PowerShell function that you nearly always pipe to Format-Table ? Wouldn’t it be nice to specify some default properties and force them into a table? Stop by for a quick hit on how to decorate your PowerShell objects with type names and formatting, including a re-usable tool to abstract out some of the details. Cheers! No related posts.

Walkthrough: An example of how I write PowerShell functions

A couple of days ago I posted a blog article titled “PowerShell function: Test-ConsoleColor provides a visual demonstration of the foreach scripting construct” and today I thought I would walk you through that function step by step since it’s what I consider to be a well written PowerShell function. It starts out by using the #Requires statement to require at least PowerShell version 3 or it won’t run. It also requires that the PowerShell Community Extensions module be installed since it uses a function from that module and continuing without it only leads to errors: #Requires -Version 3.0 -Modules Pscx The function […]

Improved Function: Get-ComputerDetail

Fellow coders, I received some great feedback from our honorary scripting guru’s Mike F. Robbins and Richard Siddaway about my little function (thanks guys! I’ll buy you a drink when we meet! 😉 ).

With their feedback I managed to improve my simple function. And that’s so great about being part of a community; people are always willing to help.

Update – What’s your favorite PowerShell Editor?

On june 9th, I’ve started a survey about the most popular PowerShell editor around: What’s your favorite PowerShell Editor? I have some results for you now, and it’s quite clear. Till now PowerShell ISE is the most popular editor. Well done Microsoft! But please keep sending in your votes, let’s make this the ultimate survey! Vote here: Survey Related posts: Working on a new PowerShell module: ProtectedData What’s your favorite PowerShell Editor? Getting a list of Windows Language Locales with Windows Powershell The Monad Manifesto Annotation Project

Function: Get-ComputerDetails

Another nice addition for today. In the forums someone asked for retrieving computer information. This information is being retrieved from several WMI objects, and had to be combined in the results. For this PowerShell custom objects are the perfect fit.

Function: Expand-ZipFile

Fellow coders, I’ve got a quick and dirty function for you. I had the requirement to extract zip files from a particular directory. Of course you could do this with Expand-Archive (new in PowerShell 5). But there’s a problem with this little rascal; it does not keeps the timestamps of the zipped files intact. My customer wanted to keep these timestamps intact, because they use it as a indicator to see if the file is older or newer what they already have. So I made a quick and dirty function, which uses a .NET assembly. I based this function on […]

Why Remoting vs. SSH Isn’t Even a Thing

As you’ve probably read, Microsoft recently announced that they’re getting on board with SSH, and that they’ve plans to, in some future-and-unspecified version of Windows, include a default SSH server and client. Some folks have taken to the Twittersphere rejoicing this decision, even though I suspect they’ve no idea why Microsoft is doing it. Others have suggested that this is the downfall of Remoting (management via WS-MAN), because who would want that when you’ve got SSH? And so now I have to write this. First of all, let’s speculate – with some objectivity – why Microsoft is getting involved with SSH […]

Trust, but Verify

The PowerShell code you write can turn up in interesting places. Production services might rely on it. Your co-workers might take a peak and borrow ideas from it. You might decide to share it online. Someone might see your code online and use it in their own solutions. Hit the link for a quick bit on how we can help create more reliable, consistent, and secure solutions. Simplified to one line: always ask yourself “what could go wrong?” What do you think? Is this over the top? Do you have any funny or awe-inspiring-train-wreck stories that resulted from assumptions around […]

DON’T Start Learning PowerShell?!?!?

Jason Helmick and I were recently up in Redmond recording a Microsoft Virtual Academy series entitled, “Building Your Datacenter One DSC Resource at a Time.” While we were there, we decided to film a tongue-in-cheek promo for the series that started with the premise that, “if you haven’t already learned PowerShell, you missed the bus.” Obviously, there’s a bit more to the story. No related posts.

Creating a small footprint, base image Part 4 | Bringing it all together with automation

In this entry I combing all I covered into a set of scripts to automate the process of creating a small footprint VHDX base image and a WIM to use a sorce that is fully patched. And I added a script to update the files on a regular basis. Check it out and let me know what you think. Creating a small footprint, base image Part 4 | Bringing it all together with automation Related posts: The current and future state of the Windows Management Framework PowerShell… An exciting frontier… The Monad Manifesto Annotation Project Series – Microsoft Certification the […]

Two New TechSessions Scheduled

Register for two new TechSession presentations. Join Dave Wyatt in his presentation on Pester and Warren Frame as he talks about Git. Registration is limited to the first 250 registrants so register now. Got to TechSession Webinars for both upcoming and recorded TechSession presentations. No related posts.

PowerShell <3 SSH

Richard’s Log, Stardate 2457176.5 Our destination for today is the love story between PowerShell and SSH. Yesterday Microsoft announced that they will integrate SSH into PowerShell. The PowerShell team at Microsoft already tried 2 times before, to get SSH into PowerShell. Now, under the wings of new management, and I think Satya Nadella has a big influence in this, they finally have a go. With SSH you can have secure, encrypted (based on strong algorithms) connections to your Windows Servers, using public/private RSA key authentication. This means that you natively can manage Linux from Windows, and vice versa, without installing any additional […]

Major Changes to DSC Pull Server Configuration IDs

Configuration IDs – Globally Unique Identifiers, or GUIDs, that DSC nodes use to identify themselves to a pull server – have always been a limiting factor in DSC design and architecture. In the April 2015 preview of WMF5, however, Microsoft has completely overhauled Configuration IDs. If you’re working with DSC, this is must-have information. No related posts.