I was able to set PowerShell aliases for every SharePoint 2010 PowerShell command (yes, all 535 beta cmdlets) with a little helpful guidance from this online tutorial. You will need to update or create a PowerShell profile in order for the aliases to be available each time you run the SharePoint 2010 Management Shell (PowerShell). I’m sure not all of these will be that useful, however, it makes it nice to only have to type gs for Get-SPSite or asol for Add-SPSolution. Anything to make our job quicker and more efficient is always a plus!
Walkthrough
First, you need to locate your PowerShell profile or create one if it does not already exist. I followed the steps in the tutorial, but here they are again for quick reference.
Step 1: Test the existence of a profile
Test-Path $Profile |
If the result = False. You will need to create a profile, so continue to step 2.
If the result = True. You have an existing profile. Skip to step 3.
Step 2: Create a profile
New-Item –Path $Profile –ItemType file –Force |
Step 3: Open the profile
notepad $Profile |
Note: The file will be blank if you just created one.
Step 4: Add Set-Alias commands
Add all of the statements (or perhaps just the ones you want) from this doc file into the Microsoft.PowerShell_profile.ps1 file
Step 5: Save the profile and give it a try!
Save the profile, close notepad, and close any open PowerShell console.
Open SharePoint 2010 Management Shell
To see if it worked type:
gs -? |
How to find an alias:
To find the alias for any SharePoint 2010 cmdlet type:
Get-Alias –definition <name of cmdlet> |
Don’t like an alias I used? No problems, edit the alias in the profile, save it, reopen SharePoint 2010 Management Shell and off you go!
A big thank you to www.powershellpro.com for the excellent tutorial, check it out for all sorts of helpful information!
11/19/2009
PowerShell