Scripting Blog [archived]

Formerly known as the "Hey, Scripting Guy!" blog

Latest posts

Dec 21, 2016
Post comments count 0
Post likes count 0

Curly Blue and the meaning of scripting – Part 1

Doctor Scripto

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...

Dec 7, 2016
Post comments count 0
Post likes count 0

Make Visual Studio Code more like the integrated scripting environment

Doctor Scripto

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...

Dec 5, 2016
Post comments count 0
Post likes count 0

Get started with PowerShell development in Visual Studio Code

Doctor Scripto

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...

Nov 25, 2016
Post comments count 0
Post likes count 0

PowerTip: Capture the output of a Linux application in PowerShell

Doctor Scripto

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.

Nov 25, 2016
Post comments count 0
Post likes count 0

Open Source PowerShell – Part 4

Doctor Scripto

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...

Nov 18, 2016
Post comments count 0
Post likes count 0

PowerTip: Return a status code to Linux from PowerShell

Doctor Scripto

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 }

Nov 18, 2016
Post comments count 0
Post likes count 0

Open Source PowerShell – Part 3

Doctor Scripto

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...

Nov 11, 2016
Post comments count 0
Post likes count 0

PowerTip: Get the status code of a PowerShell script in Bash

Doctor Scripto

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:

Nov 11, 2016
Post comments count 0
Post likes count 0

Open Source PowerShell – Part 2

Doctor Scripto

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...