Knowledge is PowerShell

PowerShell

If you’re an admin like me using PowerShell to manage your network, if you manage products like IIS, AD, System Center, Exchange or VMware: you have a chance to be part of a very select community at a very special summit.

If you want to meet the product teams, including the PowerShell team, hang with MVP’s and folks that breath PowerShell everyday in the real world, you can’t miss this summit.

Did you know that the PowerShell Team specifically wants to here from Admins that use PowerShell everyday? Why not meet them, help them understand what you do for a living.

Have some feedback? Have an issue you just can’t seem to figure out with PowerShell? Maybe those productX cmdlets are a little confusing … why not get your problems solved and help build a strong community all at the same time?

This is a time for everyone using PowerShell; Admins, Toolmakers, Developers – to get together in one place and learn from each other. The future to Microsoft IT is DevOps and it begins at this summit.

Money? Yea, this is the most affordable conference you will ever attend. The PowerShell Summit is put together by the PowerShell.Org community, focused on supporting the entire community. It’s a not-for-profit conference, so the cost is absolutely the minimum. Take a look at an article by Don Jones breaking down the expense. The reason for keeping the cost so low? – So PowerShell Admins have no excuse not to attend.

And because IT is shifting to DevOps, invite a PowerShell Developer in your office to come along with you. You might just find that you can solve amazing business problems together instead of apart.

I work with other PowerShell Admins and having separate profiles on our machines that load the same settings, functions and modules can be a pain to keep current. I started using a common profile; one that is shared from a server so making changes and additions was one step. I also wanted to start placing our Tool modules in a central location. I thought I would take a minute and show how I did it and some of the problems I ran into.

Also, I wanted to finally get the execution policy changed to “AllSigned”. A common profile, whether on a network share or Dropbox, needs to be signed if you’re using an execution policy of “RemoteSigned” or “AllSigned”, so I’ll show you how I solved this as well.

The Tools

You don’t need much in the way of tools for this exercise. You can use Notepad to edit the profiles and PowerShell to sign them. I’m going to be using a new tool from SAPIEN called the “PowerShell Profile Editor”. I’ve been playing with it for a while and I really like it for managing local and remote profiles. If you have any registered SAPIEN software you can download it for free from your account, but you can also get it from one of their ToolKit CD’s. I have some of these CD’s if your going to be at TechMentor and I’ll give you one. Here is the blog from SAPIEN explaining more about it.

The Shared Profile

So, making a shared profile is fairly straightforward. Create a network share on a local server (or Dropbox if you want). Make sure to set permissions for only you and your administrative friends.

Create a profile (text file with a .ps1 extension) and you’re good. In my case, I also wanted the shared profile to load a ToolsModule that we all use. I copied the ToolsModule to the same network share and added the last line to import the module.

Figure 1 – My new shared profile located on a servershare

The local Profile

Now, how to get that darn shared profile to load on my computer when I launch a PowerShell console…

Easy, have each PowerShell admin change their local profile to load the shared profile. Did you know that you could do that? Take a look at my example. Pretty cool huh?

Figure 2 – Configuring the local profile to open the shared profile from the server share

The Test #1

So, to test to see if it worked I opened a PowerShell console. Notice I also used tab completion to see if the function in the profile and a function from the module worked.

Figure 3 – Testing the shared profile and module

Problem #1

The problem is that I’m using a very bad and very unsafe execution policy of “unrestricted”. I want to change this to “AllSigned” but as soon as you do you will receive the following error:

Figure 4 – Execution policy error when I attempt to use AllSigned

Solution #1

The solution is to sign the profile and any additional modules. This is not a hard task but if you haven’t done it before it can be a little confusing. You first need a code-signing certificate on your computer. I chose to use Active Directory Certificate Services for this because all the Admins could install the cert. If you haven’t done this with ADCS before check out this article written by friend Mike Pfeiffer.

You can use PowerShell to the sign the profile, but SAPIEN’s Profile Editor already has this feature (like PrimalScript and PowerShell Studio). Open the File menu and click Options after you have installed the code-signing certificate. Select the option “Sign Scripts when saving” like my example below:

My next problem was no surprise I just hadn’t planned on dealing with it yet. With all the admins using a shared profile and tool module change-control quickly became an issue. If one admin makes a breaking change, then everyone has a problem! I need the ability to quickly rollback to previous version and be able to track changes.

This is a problem that developers have solved for a long time with Source Control. For most admins using PowerShell this is a new concept, however one that is going to grow as more shared scripts, module and profiles become the norm.

Unfortunately, implementing a good source control solution can range from big complex products designed for development teams to Duct-Tape-and-Bailing-Wire solutions using Dropbox. What I need is a simple solution that’s easy for admins to use that also is a professional product that doesn’t have all the cost and complexity involved with other solutions.

Solution #2

My solution? I don’t have one yet but I’m trying one out that I think is going to fit perfectly. I’ll share the details in a later blog post on my experience but since I already own many SAPIEN tools I’m going to use SAPIEN’s ChangeVue. It’s designed to be easy (especially for guys like me) but still provide the professional qualities I’m looking for without a complicated setup.

I’ll let you know how it goes! I hope you found the article helpful for using shared profiles and module.

You guys know how I love SAPIEN’s PrimalScript, but have you checked out PowerShell Studio? I get admins asking me all the time, “What’s the best way I can make a simple GUI tool for helpdesk?” or “I want a better scripting tool than the ISE.” Well, the not-so-obvious problem of learning to use development software such as Studio can be confusing at first if you haven’t worked with such an extensive tool like this before. So, I started writing some small Startup Guides to help my friends and students get started with Studio. It just so happens that the great folks over at SAPIEN have been kind enough to post my first article on their blog.

So, The first article is about getting the software installed and configured quickly to start using Studio for PowerShell scripting. I’m going to write additional articles on using some of the cool features of Studio such as saving your scripts as an .exe and digital signing.

If you like the article, let me and SAPIEN know, plus tell me what you want to know about so I can include it in a future article.

Now look, I’m not a gadget guy, nor do I run out and get the latest phone just because its new. I know, I’m a little weird for an IT guy. But when it comes to a new release of a high quality scripting editor, I stumble all over myself to find out if I want to buy it. Sapien Technologies just released a new version of the premier editor PrimalScript 2012 and a new product not seen from them before called PowerShell Studio. After a few hours with the evaluation versions, I’m buying

Yes, I’m gushing a little bit, it’s not often that I’m so initially impressed, so forgive me my excitement

PowerShell Studio

Think of PowerShell Studio as PrimalForms-meets-PrimalScript-meets-BugattiVeyron.

This is a PowerShell only Editor, but it has amazing features (plus many I’m just starting to figure out) from PrimalScript combined with PrimalForms. Kind of an All-in-one. After installing the evaluation version, I was amazed at how fast this puppy loads. For a full fledged IDE like this to load so fast is remarkable. Now, I’m just getting started working with it, but you have to check out the feature list!

PrimalScript 2012

I grew up with this IDE and it seems that PrimalScript has matured much better than I have. For those of you that have been living the life of a scripter in your company for a long time you have scripts written in many different languages. I know, I wish all my customers had their scripts in PowerShell too, but it’s just not cost effective to sit around and rewrite them. For this reason, PrimalScript has always been installed on my laptop because it supports so many languages, the amount of parsers in this tool means I never have to use notepad.

Check out the PrimalScript page for the feature list. This new version got an upgrade to its “look”, but it’s the under-the-hood stuff that really has got me going. Even PrimalScript loads amazingly fast, fully operational for whatever task I need. I know I keep saying how impressive the performance is for both new IDE’s, but you have to see it to believe it. I don’t know about you, but I can’t spend my entire day in front of a script editor. I’m jumping in and out, all the time, so load time matters.

Enough drooling for now. I want to stop writing this blog and go back to playing. I’m going to dig into these new releases and I’ll let you know what I find out. I have a feeling there is more in here than I have seen after just a few hours of playing. Now it’s time to put them to work in a real environment.

An amazing month to say the least. I’ve been invited to do a couple of the PowerShell sessions at TechDays in San Francisco! I’ll post my slides and demo’s after the show!

If you’re in the area, you should check it out. Here’s some of the speaker highlights.

Pacific IT Professionals is hosting a 2 day IT Professional conference in San Francisco March 22 and 23rd called TechDays SF. We have a great lineup of speakers to present on current topics that IT Professionals won’t want to miss.