MOSS MVP

I've moved my blog to http://blog.falchionconsulting.com!. Please update your links. This blog is no longer in use--you can find all posts and comments at my new blog; I will no longer be posting to this site and comments have been disabled.

Sunday, December 21, 2008

Initial Release of My SharePoint PowerShell Cmdlets

Update 4/25/2009: I’ve removed the “-gl” suffix from all my cmdlets - any examples using the -gl in the cmdlet name should be updated.

If you’ve been following my blog you’ll remember that I recently pushed out a “beta” build of some SharePoint PowerShell Cmdlets for some initial feedback and reviews.  We’ll I’ve gone ahead and incorporated the feedback that I received and I am now officially releasing the first version of my cmdlets.  The number of cmdlets has not changed from the beta build – they’ve just been cleaned up and enhanced.  I will slowly start documenting each of the existing cmdlets (there are currently 11) and hopefully be adding new ones over time.

I’ve added links to the top of my blog for quick download of either the source code or the MOSS or WSS builds of the setup packages.  At present there are no differences between the MOSS and WSS builds with the exception of my STSADM extensions which are included in the package and are a required dependency.  I’ve also updated my main index page so that it now also includes the available PowerShell commands – just select what you would like to look at via the dropdown box:

image

To install the cmdlets download the MOSS or WSS installer from the links at the top of this page (or in the right-hand column).  Once downloaded run the installer from your MOSS server using your MOSS admin account.  You will see the following screens:

  1. The initial welcome screen:
    image
  2. The EULA screen – you must accept to continue (you can find a copy for future reference in the install directory):
    image
  3. The install location – by default the files will be put at “C:\Program Files\Gary Lapointe\PowerShell Commands for SharePoint\”:
    image
  4. Optionally install my custom STSADM extensions – the extensions are a required pre-requisite but I make their install conditional so that if you have already installed the extensions you can avoid having to re-install them.  This is particularly beneficial if you are installing the cmdlets on more than one machine in the farm – you only have to install the extensions in the farm once as they will be pushed out to all of the servers by SharePoint:
    image
  5. Confirm that you are ready to install:
    image
  6. The files are then installed:
    image

Once the installation has completed you will be presented with the contents of the ReadMe.rtf file (which can be found in the install directory).  I’ve included the contents of that file below for reference:

To automatically load the snapin every time you start PowerShell create a shortcut to PowerShell passing in the -psconsolefile parameter like so:

%SystemRoot%\system32\WindowsPowerShell\v1.0\Powershell.exe –psconsolefile "C:\Program Files\Gary Lapointe\PowerShell Commands for SharePoint\Console.psc1"

The contents of the Console.psc1 file can be seen below.

<?xml version="1.0" encoding="utf-8"?>
<PSConsoleFile ConsoleSchemaVersion="1.0">
  <PSVersion>1.0</PSVersion>
  <PSSnapIns>
    <PSSnapIn Name="Lapointe.SharePoint.PowerShell.Commands" />
  </PSSnapIns>
</PSConsoleFile>

Or run the following command or add the following command to your profile script:

    add-pssnapin -name "Lapointe.SharePoint.PowerShell.Commands"

To see the help file for any of the commands type the following (where -detailed and -full are optional):

    help <command name> [<-detailed | -full>]

For example, the following command will return the full help for the get-spsite command:

    help get-spsite -full

Here’s a quick demonstration showing some of the power of one of these cmdlets, the Get-SPSite cmdlet:

image

Looking at the example above you can see I was able to quickly get a list of all Site Collections using “$sites = get-spsite –url *”.  I then output the results to the display to see what got returned.  To get some different columns I then passed in the $sites variable to the Select-Object (select) cmdlet and had it return back the Url and Usage.Storage properties so that I can see the size of all the size collections in the farm.  I could take this further and do some filtering if necessary but I’ll leave that exercise to you.

Keep an eye on my blog for more online documentation about each of the cmdlets along with lots of useful examples (hopefully :)).

9 comments:

Harley Green said...

Gary

Nice work!

What are you using for the help docs? If you're doing them by hand, take a look at:

http://blogs.msdn.com/powershell/archive/2007/05/08/cmdlet-help-editor-tool.aspx

Thanks
Harley

Gary Lapointe said...

That's what I'm using - I did one by hand just to get a feel for it and quickly started searching for a tool. The editor is definitely better than doing it by hand but it has it definitely isn't perfect (some elements, such as the copyright elements, get blanked out).

Gene said...

Hey Gary,

I am trying to install the Powershell for MOSS using the setup method on my 64bit MOSS2007 front-end server. However, I got the following error during the install process:

"Error 1001. unable to get installer types in C:\ProgramFiles (x86)\Gary Lapointe\...\Lapointed.Shaerpoint.PowerShell.Commands.dll assembly. --> Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information"

Any idea?

Thanks

Gene said...

Hey Gary,

I am trying to install the Powershell for MOSS using the setup method on my 64bit MOSS2007 front-end server. However, I got the following error during the install process:

"Error 1001. unable to get installer types in C:\ProgramFiles (x86)\Gary Lapointe\...\Lapointed.Shaerpoint.PowerShell.Commands.dll assembly. --> Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information"

Any idea?

Thanks

Gary Lapointe said...

Gene - Unfortunately I don't currently have access to an x64 machine that I can test the installer on so I'm not sure what's going on. Is there any additional info in the event log or did it get so far as to create any log files in the install directory? If so could you send them to me? You can of course install them manually using installutil (just download the source to get the dll).

Gary Lapointe said...

Gene - I noticed that there's a "\..\" in the path to the dll - is this something that is present in the install wizard?

Alex said...

Hi Gary,
I have same issue as Gene does, but on 32 bit system as well:

Product: PowerShell Commands for SharePoint -- Error 1001. Error 1001. Unable to get installer types in the C:\Program Files\Gary Lapointe\PowerShell Commands for SharePoint\Lapointe.SharePoint.PowerShell.Commands.dll assembly. --> Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information., (NULL), (NULL), (NULL).

Gary Lapointe said...

Make sure you have PowerShell 1.0 installed - if you have 2.0 installed will give you this error (I've not had time deal with that particular issue).

clarayeung427 said...

How to make sure you have PowerShell 1.0 installed - if you have 2.0 installed will give you this error (I've not had time deal with that particular issue)?

I got the same error with Gene