Apr 25, 2009

Getting Started with SharePoint PowerWebPart 3.0

I’ve just released PowerWebPart 3.0 on my iLove SharePoint project at CodePlex. What can you do with PowerWebPart?

Write reusable SharePoint WebParts with PowerShell

Features:

  • Simple HTML Rendering
  • ASP.NET and SharePoint WebControls
  • Supports WebPart Connections (Row Provider/Consumer, Table Provider/Consumer)
  • AJAX enabled
  • jQuery enabled
  • Configurable parameters
  • SharePoint Object Model
  • NEW: PowerGUI Script Editor Integration
  • NEW: Script Signing
  • NEW: Custom Editor Parts written in PowerShell
  • NEW: Central Script Repository
  • NEW: Import and Export
  • NEW: Error Handling
  • NEW: Debugging
  • No compile, no packaging, no deploy, no iis reset deployment
  • Copy & Paste deployment
  • Anything PowerShell can do :-)

One of the major improvements is the automatically script signing. Only farm administrators are allowed to edit scripts in the UI. But what is when you export a web part, change the script and import it to a web part gallery again? The signature will be broken and the script will not run anymore. So exporting and importing is now secure. The script will automatically be signed when a farm administrator clicks on ‘Apply’ in the web part's editor panel. The signing key will generated randomly on installation, but can be changed anytime later. 

For installation and configuration see documentation.

Getting Started Screen Cast:

Soon I will post a PowerWebPart Tag Cloud example…

18 comments:

Jeremy Thake said...

Where is the script stored so that PowerGUI can edit it and save it back? Can you have more than one instance of the web part in one web part zone on a page?
Performance wise, if you had 1000 users hit the page, how does the server react?
Great idea! Loving the potential for all sorts of stuff with object model and server stuff.

Christian said...

The script is stored in a WebPart property, so it wil be persited in the SharePoint Content DB.
The PowerGUI integration is done via an ActiveX plugin and JavaScript. You can have as many instances on a page as you want.
Performance is good question, I haven't tested with 1000 users. We really used it in projects for small teams - works well. But I'm really curious how it will perform with 1000 users. I or maybe someone else have to do a performance test, but unfortunatley time is very limited ;-)

SPAdmWiki said...

Thanks for answering that so quickly. Great webpart, just need to get time to use it now ;-)

Гломозда said...

How can I use Powershell 2.0POwerWebPart3.0? I have script for working with Exchange mailboxes. This script work in PowerGui command shell , but when I save this script in PowerWebPart, I have received error.

Christian said...

Hi,
Power WebPart 3.0 works with PowerShell 2.0. Maybe you can post your script to the codeplex forum, so I can have look at it...
Bye,
Christian

Yuriy Glomozda said...

Thanks for reply.
I will send my script if it need for you. But it's my general problem: I have to run simple Exchange management script,but have received error because of Exchange cmdlets absent . I have Powershell CTP2 and Exchange management cmdlets. Script in power shell have run OK. But in PowerWebPart 3.0, I think, Exchange management cmdlets don't visible. Is any ideas?
1)Powershell variable $profile in PowerWebPart is empty.
2)Add-PSSnapin "*Exch*"
will do error: Failed to grant permission to execute.

Thanks,
Yuriy Glomozda

Christian said...

Hi Yuriy,

normally it should support Add-PSSnapin. Maybe the current user hasn't the right to load the snapin. Have you done the setting int asp.config described in the readme? If you have not the webpart runs under the apppool user which is usually a very ristricted account. You can verify the current principal with:
function render($writer)
{
$identiy = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name

$writer.Write($identiy + "
")
}

Bye,
Christian

Гломозда said...

Hi, Christian

My configuration/runtime in asp.config has:
1. legacyUnhandledExceptionPolicy with enabled=false
2. legacyImpersonationPolicy with enabled=false
3.alwaysFlowImpersonationPolicy with enabled=true
4.SymbolReadingPolicy with enabled=1
Your render-function from your reply returned my Domain Administrator.

I don't understand, why my script don't work in PowerWebPart. Is there some another ideas?
Thanks,
Yuriy

Anonymous said...

Heya,

Tried to deploy the webpart on MOSS farm (Sp1). During install everything seems to be OK but after activating the feature at Site level and taking the webpart to the page a "File not found" error occures.

any advice?

Thanks, MaoT

Anonymous said...

Heya again,

So the error msg is:
---------------------------
Could not load file or assembly 'System.Management.Automation, Version=1.0.0.0, Cluture=neutral, PublikKeyToken=... or one of its dependencies. The system cannot find the file specified.
---------------------------

Stack Trace:
---------------------------

[FileNotFoundException: Could not load file or assembly 'System.Management.Automation, Version=1.0.0.0, Cluture=neutral, PublikKeyToken=... or one of its dependencies. The system cannot find the file specified.

IloveSharepoint.Webcontrols.Powercontrol..ctor() +0
IloveSharepoint.Webcontrols.PowerWebPart.CreateChildControls() +113
System.Web.UI.Control.EnsureChildControls +146
System.Web.UI.Control.PreRenderrecursiveInternal() +61
System.Web.UI.Control.PreRenderrecursiveInternal() +224
System.Web.UI.Control.PreRenderrecursiveInternal() +224
System.Web.UI.Control.PreRenderrecursiveInternal() +224
System.Web.UI.Control.PreRenderrecursiveInternal() +224System.Web.UI.Control.PreRenderrecursiveInternal() +224
System.Web.UI.Control.PreRenderrecursiveInternal() +224
System.Web.UI.Page.ProcessRequestMain(Boolean IncludeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3394

---------------------


Thanks so, MaoT

Christian said...

Hi,

you have to install PowerShell on the server.

Bye,
Christian

Anonymous said...

Heya,

yes :( sorry for that... We have Farm wirh 3 FE and 1 Indexing. On Indexing and 2 of the FEs PWS was installed but not on the 3rd.

My request went to the 3rd one :( which had PWS feature not enabled (w2k8)

argh..... I was looking everything at this time with ProcMon but without luck...

once more, sorry for that silly mistake :( Anyway thanks for the Reply

Bye, MaoT

Anonymous said...

Hi Christian

I have installed PowerWebPart 3.0 on a DEV server, and when I go to add a web part, I receive this error:

Power WebPart 3.0
iLove SharePoint PowerShell WebPart 3.0
Power WebPart 3.0

Error on Initialization
Exception:
Script is not signed!
Stack:
at iLoveSharePoint.WebControls.PowerControl.Render(HtmlTextWriter writer) at iLoveSharePoint.WebControls.PowerWebPart.Render(HtmlTextWriter writer)


Any ideas?

Memo said...

Hello Christian:

I am having problems running your PowerWebPart. The steps I followed were:

1. Runned setup in my server
2. iisreset
3. Went to a site
4. Site Settings
5. Site Features

And there I can't find the PowerWebPart.

Did I miss something?

BTW: I use the PowerActivity and it's great!

Christian said...

Hi Memo,
you should see the feature under site collection features.

Bye, Christian

Anonymous said...

I install pwp by dbl click setup.exe
go to sharepoint.. activate ilovesharepoint powerwebpart

goto add web part.. and can't find pwp in list.

then i go to add web-parts and see this:

Error on Initialization
Exception:
Script is not signed!
Stack:
в iLoveSharePoint.WebControls.PowerControl.Render(HtmlTextWriter writer) в System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) в System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) в System.Web.UI.Control.RenderControl(HtmlTextWriter writer) в iLoveSharePoint.WebControls.PowerWebPart.Render(HtmlTextWriter writer)

Christian said...

works as designed. the script that y will enter will be signed when you save it the first time (farm admin rights required)

Anonymous said...

I try to use a script in the library defined in the administration page.
The script was tested before in the webparts self.
I copy the script into a file, stored in the library and call this script by the import command.
It doesn't work.
I try to make the simplest example

function Render($writer)
{
$writer.Write("May the power be with you!")
}

and I get the error "
Error on render
PowerShell Exception:
The term 'render' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Stack:
at iLoveSharePoint.WebControls.PowerControl.Render(HtmlTextWriter writer) at iLoveSharePoint.WebControls.PowerWebPart.RenderContents(HtmlTextWriter writer)"

And idea?