PowerShell is a great companion for SharePoint 2010. As a developer, I find the best way to use it is through the Integrated Scripting Environment (ISE). The only problem is, the SharePoint snap-in doesn't load automatically when I start PowerShell ISE. So, here are the steps I follow to get ISE installed and make sure the SharePoint snap-in alwyas loads.
1. Open Server Manager
2. Click the Features node
3. Click the Add Features link
4. Check the box for "Windows PowerShell Integrated Scripting Environment".
5. Click Next, then Install
6. Wait until installation is complete
7. Open Powershell ISE from Programs>Accessories>PowerShell folder
8. Run the following code from the immediate window in ISE to create a new profile for all users
if (!(test-path $profile.AllUsersAllHosts))
{new-item -type file -path $profile.AllUsersAllHosts-force}
9. Run the following code to edit the new profile
psEdit $profile.AllUsersAllHosts
10. When profile1.ps1 opens, add the following code to attach the SharePoint snap-in every time PowerShell is run.
If ((Get-PSSnapIn -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{ Add-PSSnapIn -Name Microsoft.SharePoint.PowerShell }
11. Save profile.ps1 and close PowerShell ISE.
12. Start PowerShell ISE again and type the following command to verify that the SharePoint snap-in loaded. You should see SharePoint-specific command listed.
Get-Command Get-SP*