Friday, 25 June 2010

Windows PowerShell ISE

I know there are a few PowerShell GUI interfaces available out there, but there is actually one included with Windows Server 2008 R2. It's called Windows PowerShell Integrated Scripting Environment (ISE) and you can load it as a feature from Server Manager. It includes the following features:

  • Command prompt pane similar to the one provided with the standard PowerShell application
  • Output pane showing the results of commands and scripts executed
  • Scripting pane allowing you to create *.ps1 PowerShell script files. Commands can be copied and pasted into here from the other two panes
  • Script debugging with breakpoints
  • Script and individual line execution from the toolbar

ISE

To enable Windows PowerShell ISE for use with SharePoint, the only thing you will need to do is make sure the SharePoint PowerShell add-ons are loaded. The following steps create a Windows PowerShell ISE profile on the machine for the local user (taken from http://www.harbar.net/archive/2010/05/03/adding-sharepoint-2010-poweshell-cmdlets-to-your-powershell-ise.aspx):

  • Install Windows PowerShell ISE from Server Manager and launch it from the Accessories > Windows PowerShell folder on the start menu
  • Copy or type the following text in the Command Pane (View > Go to Command Pane) and press ENTER:

# Creates a local user PowerShell ISE profile
if (!(test-path $profile ))
{new-item -type file -path $profile -force}
# opens it for edit
psEdit $profile

  • Running these commands will open a new script file in the Script Pane. Type the following commands in the script file and save it by clicking the Save button on the toolbar:

# Copy the following into the new file and save it
cd 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration'
.\SharePoint.ps1
cd \

From now on, the SharePoint cmdlets will automatically load every time you start Windows PowerShell ISE as the same user. If you are still having problems using it, you may need to run it as an Administrator by right-clicking the shortcut and selecting Run as administrator (you can also force it to run as an administrator every time by right-clicking the shortcut, selecting Properties and then the Advanced button).

3 comments: