If you've downloaded some of my previous scripts and tried to run them from your powershell prompt, you may have gotten some "Can not find type" errors if you didn't load the Sharepoint libraries first. If you're fresh with Powershell and Sharepoint, it may not be inherently obvious how to do this so I decided to write a small guide on how I have my Powershell setup on my virtual machine.
First you need to install Powershell (obviously). I suggest you still stick with 1.0 for now, since 2.0 is still not finished. You can download Powershell from here: https://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx.
The next step is to create a shortcut to Powershell that loads a script at startup. I have mine on the desktop, but you can put it where ever you want (Quick Launch, Programs, etc). The target of my shortcut is set to: %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -noexit &"H:\Powershell\_loadSP.ps1". Obviously you're going to have to change this to make sure it points to the correct place. The first part (before the &) points to your Poweshell installation, so you can probably copy and paste this part into your shortcut. Make sure you include the -noexit command line parameter.
The second part must point to where you have your startup script located. Mine is located on my personal network drive (H:) in a folder called Powershell. The script itself is called _loadSP.ps1. You can change this to reflect where you have your script located.

The shortcut target and start in properties
For convencience, I also have the "Start in:" property set to the Powershell folder on my personal network drive. I store all my scripts in this folder, including the startup script, so it's nice to have Powershell default to this directory so I can just start typing in scripts to run them.
When you create your own shortcuts to Powershell, it doesn't set the default Powershell colors for you. So if you want the blueish background you'll have to go in and set these yourself. The colors for the background is Red =1, Green = 36, Blue = 86. For the text it is Red = 238, Green = 237, Blue = 240. Pop-up text is Red = 0, Green = 128, Blue = 128. And finally pop-up background is all white (all values 255).

The screen colors
Next we have to make that Powershell start-up script. To run any of my scripts there are just two libraries you need to load.
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") [System.reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing")
That should be all you need to get started.
I have a few extra things added in my startup script however, which lists all the scripts in the current directory, as well as their syntax and a short description. This is pretty shoddy code as I wrote it in about 5 minutes, but it works and that's all I need.
# Description # Loads Sharepoint libraries and lists scripts of current folder, as well as their description and syntax # # Syntax # ./_loadSP # # Parameters # none # # Settings # Only change the -value parameter! # set-variable -option constant -name filelen -value 16 set-variable -option constant -name syntlen -value 35 set-variable -option constant -name desclen -value 66 # End of settings "Loading Sharepoint libraries..." [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") [System.reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing") sleep -Milliseconds 300 # pause for dramatic effect cls "Sharepoint libraries loaded!" "" "Available scripts:" "" #Table formatting $n = "Name" $s = "Syntax" $d = "Description" $fspcr = " " $sspcr = " " for($c = 0; $c -lt $filelen - $n.length; $c++) { $fspcr += " " } for($c = 0; $c -lt $syntlen - $s.length; $c++) { $sspcr += " " } for($c = 0; $c -lt $n.length; $c++) { $ndsh += "-" } for($c = 0; $c -lt $s.length; $c++) { $sdsh += "-" } for($c = 0; $c -lt $d.length; $c++) { $ddsh += "-" } $n + $fspcr + $s + $sspcr + $d $ndsh + $fspcr + $sdsh + $sspcr + $ddsh # Find all .ps1 scripts $files = Get-ChildItem | where { $_ -like "*.ps1" } # lets list contents of folder... foreach($file in $files) { $filecontent = Get-Content $file.Name # Retrieve syntax $syntax = $filecontent[4].substring(2) if($syntax.length -gt $syntlen) { $syntax = $syntax.substring(0,$syntlen-3) + "..." } # Retrieve description $desc = $filecontent[1].substring(2) if($desc.length -gt $desclen) { $desc = $desc.substring(0,$desclen-3) + "..." } # Format column one $fspcr = " " for($counter = 0; $counter -lt $filelen - $file.Name.length; $counter++) { $fspcr += " " } # Format column two $sspcr = " " for($counter = 0; $counter -lt $syntlen - $syntax.length; $counter++) { $sspcr += " " } # Let's print the content $file.Name + $fspcr + $syntax + $sspcr + $desc } # Changelog # # v1.0 - November 27th, 2008 # First public release

Powershell start-up script loaded




