PowerShell Blogging Week is Coming

talkbubbleAs I’m sure you are aware there is a lot of great PowerShell goodness online through social media and blogs. Well, I and a few members of the PowerShell community have banded together to add to that goodness. During the week of March 30, look for new daily content from the group. Our topic is advanced PowerShell functions and we will each be contributing a post on our respective blogs covering some aspect of that topic. Naturally, we’ll also be spreading the word through Twitter and other social channels. We hope you will get involved by posting comments or connecting with us on Twitter.

I don’t want to spoil the surprise about what we’ll be covering, but these are the people involved. If you aren’t following them now, you should be:

We will be using the hashtag #PSBlogWeek. This should be a lot of fun and informative so we hope you will join us.

Friday Fun: Size Me Up

Part of day job involves creating training material, often in the form of video training for Pluralsight or articles for Petri.com. Since I usually am covering PowerShell I often need to capture a PowerShell session. And sometimes I want the screen to be a particular size. So over time I’ve created a few PowerShell tools to resize console and application windows. The PowerShell console window stores its dimension under $host.ui.rawui.windowsize.

These are the same settings you would see here:

As long as you use a value less than the buffer dimensions, you can modify the console window from a prompt. But it takes a step you might not realize. You can’t do this:

Instead, you can create a new type of object with your intended dimensions.

Then you can use this object as a value for the WindowSize property.

Naturally, I created a function to do this for me.

My function also includes code to support –WhatIf.

Of course now that I’ve shown you that I have an alternative. You can use the .NET class [System.Console] which has properties for width and height. And you can set these values independently.

You can’t discover this unless you know something of the .NET Framework, but you could have discovered $host which is why I showed you that first. Since I often need to record video at 1280×720 dimensions, I wrote a quick and dirty script to set my PowerShell console window to those dimensions.

Everything I’ve shown you so far is for the PowerShell console. But what about the ISE? You can’t use the techniques I’ve covered. Application windows are bit more complicated and I’m not going to go into the details. But I came across some code on GitHub (https://gist.github.com/coldnebo/1148334). I don’t do Minecraft but it didn’t take much to turn it into a re-usable function.

The code supports –WhatIf and defaults to the current application, which is presumably the PowerShell ISE.

But this is what actually gets set.

So if you wanted to include the title bar you would need to adjust accordingly.

All of this may not really be applicable to your work, but if you find a good use I hope you’ll let me know. Have a great weekend.

DevOps Twitter Chat

DevOpsChat-tw_v1_sd This Thursday, February 26, I will be doing a live Twitter chat from 12PM to 1PM EST. The topic is DevOps but I’m sure we’ll talk about PowerShell and automation in general. Use hashtag #DevOpsChat to submit questions and follow along. You can follow me on Twitter as @JeffHicks. I hope you’ll join me.

Advice, solutions, tips and more for the lonely Windows administrator with too much to do and not enough time.