PowerShell V3 ISE Mistakes(?)

Yup, as I write this blog I know that my friends will hate me, the people I respect the most in the PowerShell community will never speak to me again, my family will disown me and the dogs won’t even look up at me. While I feel a knot of shame building in my gut, I’m dumb enough to still write this blog. See if you can at least make it to the end before you remove me from your LinkedIn/Facebook/Twitter/Party invite/Will list.

So, the talk of the town as PowerShell V3 nears release is the new Integrated Scripting Environment (ISE) and the leaps it has made over the old one. For the most part I agree, but as I sit back and listen to how both Microsoft and the PowerShell community are “Marketing” the ISE I begin to wonder “who” was this tool made for? If it was for admins, is everyone missing the best part in the design and usability? Let me approach this as I approach everything as a simple admin working day-to-day with PowerShell.

It’s the economy, stupid

Most admins still think PowerShell is a programming language instead of an interactive command line shell. Once you finally convince them (or teach them) how wonderful a shell can be, they dive in with zeal, amazing effort, and eventually incredible success at using PowerShell as it was intended. Thanks to guys like Don Jones, admins are starting to realize this tool was made for them.

PS> Enter-Shell -Console sucks | Select-Object -property Result | 

 >> Format-List

 >> 

Result : 30+ year old console

So, the old console that holds your precious PowerShell is a disease that can’t be cut out. Admins hate the old console, not because they are afraid of command line, but because it’s painfully stupid/hard to use. Let’s face it, it’s the 21-century and I didn’t get my flying car, but can I at least have a console that can Cut/Paste like everything else? Developers have had the solution at their finger tips for years – syntax highlighting to reduce typos, popup help as you type (IntelliSence) and error checking as you type – things that keep you from screwing up.

This is where PowerShell V3 ISE finally comes to the rescue. I fantasize that some genius somewhere in the PowerShell team had a thought: “If I can’t fix the console, then F*&$ the console, I’ll make a new one.” Bravo!

Notice in Figure 1 the new console view in the ISE. Of course you will need to finagle around to get this view as no one made this the default. So, turn off the menu toolbar, select a single pane and so on. The ISE is likely to launch with the scripting pane first but you can flip to the console quickly with Ctrl-R.

 

Figure 1 – The new console

Of course as you type you get wonderful syntax highlighting. Take a look at figure 2 and ask yourself is this is not the best console in the world!

 

Figure 2 – Syntax highlighting

This is what every console admin dreams of. Thank you PowerShell Team. Now for the stuff that gets me into trouble, here is what I wish for in the world of Jason:

  • I wish – this clean full screen console was the default view.
  • I wish – the ISE didn’t opened up to the script pane first (more on this later).
  • I wish – this was advertised as the replacement to the old console.
  • I wish – the icon on the Taskbar for the old crappy console was removed and replace with this.
  • I wish – for world peace and six-pack of beer for everyone on the PowerShell team for working so hard.

For the everyday admin using PowerShell the beauty of this design is perhaps the most important feature of V3, unfortunately somewhat buried. Shame, I think the economy of usability could have been enhanced here.

It’s all in a name

I had an idea the other day: pretend for a moment that the console admin was the sole focus of the ISE design. The new console would have all the features discussed above, with a simple and quick scripting editor that you could flick too (ctrl-r) when you needed to write quick automation, maybe even a simple advanced function. Of course, you would want to copy/paste (like a normal human) from the console view to the script pane view (hmmm, I think it does that now).

Then I thought the name of this tool would very important. It’s a console that has some simple scripting capabilities. Almost a 70-30 split. So, wouldn’t a name like Integrated PowerShell Environment (IPE) be cool? It seems inviting to an admin that has stalled learning PowerShell because of the words “Scripting” and “Programming” and “Developing”. In fact, they might even learn to automate without really knowing they had become a scripting toolmaker.

Scripting/Toolmaking/Automation/Business solutions/IDE

Is the ISE right for toolmaking in complex situations? You tell me.

I have a highly biased opinion about the kind of tool I need when I’m writing a module, a complicated advanced function or a WinApp for Helpdesk. The ISE just doesn’t fit the bill for me in those cases and I choose to use a professional IDE with great debugging, signing, packaging, etc. (most of you know which one).

Because of my bias I won’t take the scripting side of the ISE to task other than to say it’s much better than V2 ISE and the PowerShell team should be proud.

Did I cry wolf or run afoul?

PS> Set-Flame –Intensity High –ComputerName Jason –On

So, are you mad at me? Did I raise any valuable points? Did I manage to show you how you can use the new ISE as the best damn console in the World?

Knowledge is PowerShell,

Jason

 

PowerShell V3 Cool Trick with Arrays/Collections

Note, this only works with Windows Management Framework Beta.  Not CTP1 or CTP2.

So I don’t know what this nifty little feature is called, but I stumbled across it today and just had to share.  I think this might come in handy, in fact, it might become super useful!

So, let me do something unusual for this blog and get right to the point.

In PowerShell V2, this worked as expected.

PS> $Service=Get-Service bits

PS> $Service.name

Screen Shot 2012-03-09 at 5.08.32 PM

But if I tried this…..FAIL!

PS> $Services=Get-Service

PS> $Services.name

So, to fix this problem, we have become accustomed to using Select-Object, or worse, the dreaded Foreach-Object.

PS> $services | Select-Object –Property name

If you just needed the strings, such as in a parenthetical for a parameter, you would use –ExpandProperty

PS> $Services | Select-Object –ExpandProperty name

Version2

Well, look what I noticed with PowerShell V3.

PS> $Services=Get-Service

PS> $Services.name      — IT WORKS!

Versioon3

I don’t know what this feature is called, but imagine the time savings this could make.  Of course this works with properties, but how about methods?  So I quickly tried the first method I could think of…..(Yes, I ran this, but you should not!)

PS> $Proc=Get-Process

PS> $Proc.Kill()

killproc

Yup, it does exactly what you think it does.

Note to self when working with PowerShell; So, whose your daddy?

Knowledge is PowerShell,

Jason

Installing an AD Domain Controller with Windows 8 Server and PowerShell V3

**Note:  This demonstration is using the Windows 8 Server Developer Preview**

ok folks, first a huge disclaimer.  Don’t do this on a production network, or even think of being plugged into one.  I’m going to demonstrate a cool new way to make a domain controller.  If you don’t understand the old DCPROMO settings, don’t do this. Do this on a VM that has no connectivity to your network.  Consider yourself warned.

Next, If you start playing with PowerShell V3 CTP1 or the Preview release, be sure to let the PowerShell Team know if you run into any bugs on Connect! Don’t be shy, it’s our PowerShell, let’s make it the best we can!

Let’s begin…

So, I’m playing with Windows 8 Server (core).  All of the new PowerShell support is incredible.  I decided that I wanted to see if I could make a quick AD environment for some testing.  Here’s what I did.

First, while I originally did this in pure Core, I’m performing this demonstration on a “Full” install, just so you could see the end results in a pretty GUI.   Also, I’m NOT pre-configuring DNS, I’m just going to let the “cmdlet” do all the work like the old Wizard.  While this is not a good idea in real life, its fast and easy for a quick test environment.  I’ll post a “proper” Pre-AD DNS configuration blog later.

To show that I’m not cheating, here is the currently installed software on my Windows 8 server.

Import-Module ServerManager

(yes, the new cmdlets dynamically load, but I’ve been having issues getting Get-Windowsfeature to load, so I’m just doing this the old fashioned way for now.)

Get-WindowsFeature | where installed –eq True

P.S.  This could also be

Get-WindowsFeature | where installed  (cool huh!?)

1-showing isntalled

I first wanted to see what  “AD” goodness was available.  Server 2008R2 had a Role that you could install, just wanted to make sure it was still there.  It was, but the install name changed to AD-Domain-Services.

Get-WindowsFeature ad*

2-looking for ad

If you did this in Server 2008R2, you would type add-windowsfeature and the role name.  There seems to be a little verb confusion in the Preview.  (I’ll call it “Verb-all abuse Winking smile)  You can use Add-WindowsFeature or the new form Install-WindowsFeature.

Install-WindowsFeature AD-Domain-Services

3-install ad files

This, as you know, installs all the stuff you need for an implementation of Active Directory.  If this was Server2008R2, you would now run DCPromo, BUT ITS NOT!  MuHahahahah…

So,  I wanted to discover what new things might be available to see if I could do the installation of AD without Dcpromo.  This is where the power of the PowerShell Help system comes into play.  I started to try some cmdlet discovery with Get-Help.  It just so happens I hit jackpot on the first thing I tried.

Get-Help Forest

get-help forest

The reason this works is that the PowerShell help can now see cmdlets in other modules, even if those modules aren’t loaded.  How freaky cool is that!?!  Do you see what I see?  Install-ADDSForest located in a  module called ADDSDeployment.

I suppose you could have also found this by doing a module list too, but why work harder reading the screen than you have too.

Get-Module –ListAvailable

4-get-mod

You’ll notice that there is a module called ActiveDirectory, which is similar to the one we had in Server2008R2 (Although greatly improved cmdlet’s now)  But you will notice the other module called ADDSDeployment!

I know the cmdlet I want to examine, but before I did, I loaded the module and just did a quick command list.

Import-Module AddsDeployment

Get-Command –mod AddsDeployment

5-command list

I did a quick Get-Help on the cmdlet I found, Install-ADDSForest.  Now, this is a preview release and there isn’t much help other than syntax.  But if you have run DCPROMO before, you can easily figure out the parameters.

Get-Help Install-ADDSForest

6-get-help

So let’s do this baby.

Install-ADDSForest –DomainName Widget.local

–DomainMode Win2008R2 -ForestMode Win2008R2 –InstallDNS

–SafeModeAdministratorPassword (Get-Credential).password

8-runningcommand

YAHOO!

9a-installing

So, what did I get?  Take a look at the pretty Gui’s.  By the way, you don’t need these GUI things anymore, but that’s for a later post.

ADUC

10 aduc

DNS

11 - dns

Wow!  This was great!  By the way, I decided to see if I could remove my new Forest and Domain…..

Uninstall-ADDSDomainController –LocalAdministratorPassword (Get-Credential).password –LastDoaminControllerInDomain –RemoveApplicationPartitions

13-removal

How freaky cool is that!?  Basically, you can build a DC with a one-liner!

HEY!  If you start playing with PowerShell V3 CTP1 or the Preview release, be sure to let the PowerShell Team know if you run into any bugs on Connect!  Don’t be shy, it’s our PowerShell, let’s make it the best we can!

Knowledge is PowerShell,

Jason

Windows 8 PowerShell Preview!

Well, darn.  I started to take screenshots and everything as a first look at PowerShell in Windows 8, but my buddy Mike Pfeiffer beat me to it.  Rather than just steal hist blog go check out his link….

 

http://www.mikepfeiffer.net/2011/09/windows-8-developer-preview-and-powershell-v3-first-look/

AND This one!

http://www.mikepfeiffer.net/2011/09/windows-server-8-developer-preview-and-powershell-v3-first-look/

 

(he’s an exchange guy, why does he keep mooching my stuff?  –I love him, but I’ll have to hurt him.)

Also, check out my new list of PowerShell V2 and soon V3 classes that are available here at Interface!

http://www.jasonhelmick.com/powershell

 

Knowledge is PowerShell!

Jason