Home

Black Mountain

My Experiment on the Internet

Setting up a PowerShell environment

Having really gotten excited about PowerShell, I have been getting more friends and co-workers to like and use it. So this post is links to downloads and instructions for setting up PowerShell and some of the tools I use so I don't have to repeat myself so much. I freely admit that I am still learning but this will at least get your environment setup quickly (and since we manage VMware servers where I work, links for them are provided).

Download PowerShell v1.0 from Microsoft
Download Quest PowerShell commands for Active Directory
If you use VMware, then download the latest VMware PowerShell tools.
Download PowerShell Plus from Shell Tools

  1. Install PowerShell
  2. Launch PowerShell
  3. Read up on PowerShell security somewhere but for now run
    Set-ExecutionPolicy RemoteSigned
  4. Close PowerShell

Install Quest PowerShell commands for Active Directory.
Optional : Install VI Toolkit for Windows

So, now you have PowerShell and some other cool tools installed. Each of these tools has added a link to a PowerShell interface that accesses their tools but really, is that what you want? No. You want one window to rule them all. If you run the Add-PSSnapin Quest.ActiveRoles.ADManagement command, you will now have loaded the Quest commands, but we don't want to do that each time do we?

Onto profiles. Look in your My Documents directory, is there a directory named WindowsPowerShell? If not create one. In that directory create a text file named Microsoft.powerShell_profile.ps1. PowerShell commands and functions here will run when you first launch PowerShell. You can use # sign's for comments. I have learned to appreciate commented code, both as a memory aid for why/what something does and for when I give a copy to others to reduce questions, such as pasting it in my blog.

Here's whats in mine:
Note, choose a path to your scripts directory to fit your needs and work habits. Doing this allows you to cd ps: to get to your scripts directory root..

# Create drive to PS Scripts directory
New-PSDrive -Name PS -Root C:\support\scripts\powershell -PSProvider filesystem

# Set location to PS Scripts directory
Set-Location PS:

# Add Snapins
Add-PSSnapin Quest.ActiveRoles.ADManagement
Add-PSSnapin VMware.VimAutomation.Core

Restart your PowerShell. You should have access to all the extensions you've installed now. To see what extensions are available to your system run Get-PSSnapin. At this point, environments pretty cool. You can change the colors and everything but we're not quite done yet.

You need an editor. Anything that edits text can edit a PowerShell script. Notepad for instance will work, but notepad? Come on! I tend to use Notepad++ for various things and you can download a color context highlighting script and register it to make everything into pretty colors. Colors that really do help spot the typo and such. However, there is better.

I have the zip version of PowerShell Plus. Unzip it in a suitable directory now (it unzips to a \psp1). Launch PowerShellPlus.exe and walk through the wizard. I choose;

  • Save settings inside my application folder only
  • Uncheck the box - Run Wizard on each start. You can enable the wizard through the GUI if you add more extensions later
  • Load the private Microsoft profile scripts to ensure maximum compatibility
  • First time - Yes, please update the database when the wizard closes
  • Accept the agreement - free for hobby / personal, cheap for a real license and come on, it's only a couple of guys so cough up the money

The wizard runs through all the Snapins and looks at some other stuff (no, I don't know). It updates the tab completion database which is sweet!

This is your console. You have various tools you can explore but to start with click on the code editor button. There's your fancy Office 2007 style editor.

That's my environment. Your turn to start playing and learning how to make your job life easier. Let me know how it goes!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h3> <blockquote> <img>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

Sometimes I get asked, so here it is ... My Amazon.com Wish List

Thought I'd see what this Technorati stuff does.

Login with your @drupal.org user id or your OpenID to leave unmoderated comments
contents copyright Steven Peck - powered by drupal logo