Scripting Blog [archived]

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

Latest posts

Jun 15, 2018
Post comments count 0
Post likes count 1

PowerTip: Use PowerShell to play WAV files

Doctor Scripto

Make use of the native features of Windows through PowerShell to play sound.

Jun 15, 2018
Post comments count 0
Post likes count 0

Windows PowerShell and the Text-to-Speech REST API (Part 4)

Doctor Scripto

Send and receive content to the Text-to-Speech API with PowerShell.

Jun 12, 2018
Post comments count 0
Post likes count 0

PowerShell PowerTip: Grabbing the location your script lives in

Kory Thacher

One super common thing in PowerShell is to design a script to consume particular files for data. Often times you are building the script right in the folder for your files. However, it can be annoying to give long, literal file paths to a file. Also, if you give that script to someone else, they need to edit that path to point at the right location-- how annoying! There is a built in variable to help with this scenario: $PSScriptRoot will provide the file path the script was run from, which can let you relatively point at files. You can see an example of this in an older blog post. I received a few questions ab...

Jun 5, 2018
Post comments count 1
Post likes count 7

Working with JSON data in PowerShell

Kory Thacher

Welcome back everyone! This week we will take another look at some common data types we might encounter in the real world: JSON data. JSON data is used pretty frequently on the web if you're hitting APIs. This not only includes external data (twitter, weather, marvel database), but often includes internal data to your company. It's nice to be able to leverage data from anywhere, and it can be frustrating for people to try to parse JSON data. Luckily, we have this all built in for you using ConvertFrom-JSON I'll get a response from an API online used for testing: The response data looks like this: A...

May 31, 2018
Post comments count 0
Post likes count 1

PowerTip: Ensure that errors in PowerShell are caught

Doctor Scripto

Here’s how to make sure your errors get caught with <strong>Try Catch Finally</strong>.

May 31, 2018
Post comments count 0
Post likes count 0

Windows PowerShell and the Text-to-Speech REST API (Part 3)

Doctor Scripto

Use Windows PowerShell to access the Cognitive Services Text-to-Speech API.

May 30, 2018
Post comments count 0
Post likes count 0

PowerShell PowerTip: ISE crashing and auto complete not working

Kory Thacher

Hi all, I'm going to start putting out these short PowerShell PowerTips every so often. They won't be full blog posts, but they will be short and useful! Have you been having issues with the ISE crashing and not auto completing since windows update 1803? From what I've seen there is a fix for this coming, but if you need these features now you can try the 2016 ISE preview To try it run as an admin and do this: Then go ahead and pin it while you wait for the fix. You can also check out VS Code Happy PowerShelling!

May 23, 2018
Post comments count 0
Post likes count 0

Run PowerShell code in Puppet

Doctor Scripto

Normally, it’s preferable to use specific Puppet and DSC Windows modules to manage systems in Puppet, but an alternative is running PowerShell commands and scripts by using the <strong>exec</strong> resource. This can be helpful for transitioning existing PowerShell code into Puppet quickly.

May 15, 2018
Post comments count 0
Post likes count 1

Doing more with functions: Verbose logging, Risk mitigation, and Parameter Sets

Kory Thacher

Welcome back to PowerShell for Programmers, this week I'm trying gitGist again for the code blocks. Let me know what you think about it vs the normal syntax highlighter I use :) As we've seen in the other posts about functions, attributes are a really cool thing to extend the features we have available to ourselves and for our users. This post is going to deal with an attribute for the function itself as well as ones for the individual parameters. This will let us make our functions behave more like any other cmdlet, by giving us access to the common parameters that users are used to seeing. Common Parameters...