The “Hey, Scripting Guys!” blog has been retired. There are many useful posts in this blog, so we keep the blog here for historical reference. However, some information might be very outdated and many of the links might not work anymore.
New PowerShell content is being posted to the PowerShell Community blog where members of the community can create posts by submitting content in the GitHub repository.
Scripting Blog [archived]
Formerly known as the "Hey, Scripting Guy!" blog
Latest posts
Curly Blue and the meaning of scripting – Part 1
Summary: Curly Blue learns how to automate cleaning of old data files by using PowerShell. This week, in the spirit of the holidays (and of course the previous six years!), Hey, Scripting Guy is honored to bring forth a repeat of a tradition: The “Hey, Scripting Guy!” holiday special. This year, we are pleased to offer a week of fun and Windows PowerShell with a new story produced as a collaboration of two MVPs, Honorary Scripting Guys, Thomas Rayner and Sean Kearney. This year’s special is about a fellow named Curly Blue who has just started his new job with only a week remaining before the holiday weekend. C...
Make Visual Studio Code more like the integrated scripting environment
Summary: Learn some handy tips to make Visual Studio Code work more like the ISE. I was very intrigued with the release of Visual Studio Code last year. An editor that is light-weight and integrated with Git is something worth considering. Well, any new tool that could be added to the tool box is worth considering. In the past, I used the integrated scripting environment (ISE) as my tool of choice to develop and edit PowerShell scripts but I’m always looking for ways and tools to improve my PowerShell skills. There is a learning curve to Visual Studio Code. The ISE is very intuitive. I have never had much troub...
Get started with PowerShell development in Visual Studio Code
Summary: Learn about the features in Visual Studio Code that help you write PowerShell code. Since the PowerShell integrated scripting environment (ISE) shipped with Windows PowerShell 2.0 in 2009, the PowerShell landscape has changed significantly. In November 2014, Microsoft took .NET open source and cross-platform. Given PowerShell’s dependence on .NET, this was an important prerequisite before taking PowerShell cross-platform. And, indeed, nine months later, Microsoft made PowerShell available cross-platform, supporting Linux and macOS in addition to Windows. To the surprise of many, Microsoft also open-sour...
PowerTip: Capture the output of a Linux application in PowerShell
Summary: Use the built-in features of PowerShell to obtain data produced by a Linux application. Can I run a Linux application like ls and capture its output in PowerShell? You certainly can! It’s no different from when you normally grab output from any other command in Windows. To grab the output of the ls command, for example, just assign it to a PowerShell object as you normally would. The captured output will be all text, and you can run standard methods, Search-String and regular expressions against it.
Open Source PowerShell – Part 4
Summary: Install and Configure SSH for Open Source PowerShell remoting. With PowerShell, up to this point, one thing that I love is the ability to connect various systems in my environment and run cmdlets on them remotely. Can we do this with Open Source PowerShell? Honorary Scripting Guy, Sean Kearney, is here today to go over how to get Open Source PowerShell set up to do remoting. Because this, my friends, this is the big game changer. When Linux admins presently need to work with a Windows Server, they need to play with a few options: A Windows admin could typically just download a utility l...
PowerTip: Return a status code to Linux from PowerShell
Summary: Pass a result code back to a calling Linux environment from Open Source PowerShell. How can I pass a numeric value back to a calling Bash Shell to indicate an error? Just simply supply the EXIT command and a numeric value at the point where the error is flagged. For example, the following code is a PowerShell script that returns a value of 76 if the script does not match the value of . If ($Value -eq ‘Something Good’) { Write-Output ‘It’s Good, it’s very Good’ } Else { Exist 76 }
Open Source PowerShell – Part 3
Summary: Pass and return data correctly between Bash and Open Source PowerShell. Could you show me some examples of actually passing and returning values between PowerShell and Bash? Honorary Scripting Guy, Sean Kearney, is here today and we’ll do exactly that. It isn’t difficult to actually to do this either, but there are two things to keep in mind to make all of this easier. When working with data: If you keep this in mind, much of the challenge is in just understanding that when PowerShell parameters are set, they should be typed correctly by using the appropriate .NET class. You’ll also need to...
PowerTip: Get the status code of a PowerShell script in Bash
Summary: Identify the results of a script running in Open Source PowerShell in a Bash environment. Is there any way to see the results of a PowerShell script? For example, if somebody sent an “Exit 42”, could I see it in Linux? All you need to do is examine the $? variable in Linux, just like any other Linux application. Here is an example:
Open Source PowerShell – Part 2
Summary: Use PowerShell scripts within Python and Bash (and those within PowerShell). I am curious just how much I can use Open Source PowerShell within Linux and macOS. Is it an isolated environment, or can it interact with other shells? Thanks for your question. Our good friend, Honorary Scripting Guy, Sean Kearney, is here today to show you just how well it interacts. Let’s consider something. Most shells, whether it is Bash or CMD.EXE, are just that, a shell. They normally can run some processes and send output to the console. In many cases, those same shells can call up other shells and launch others...