Sep 30, 2008

SharePoint PowerWebPart V1.0 Released

I've just released the PowerWebPart V1.0!

Execute PowerShell Script in a WebPart
Just perfect for agile SharePoint Development!

    • Simple HTML Rendering
    • Use ASP.NET and SharePoint Controls
    • Supports WebPart Connections (Row Provider/Consumer, Table Provider/Consumer
    • No compile, no packaging, no deploy, no iisresets
    • Anything PowerShell can do :-)

Documentation and examples coming soon!

Bye,

Christian

Sep 29, 2008

Select-SPListItem

I've added a new function to my PowerShell Script Profile called Select-SPListItem.  Usually you have to select the SPListItem's columns via the indexer like $item['Title']. This approach doesn't work great with built in cmdlets like select-object, group-object, sort-object, nor with tools like PowerGadgets (out-chart :-). The idea was to built a function similar to select-object, see below. Yo can use it like this:

$list.Items | Select-SPListItem Title, TaskStatus | group-by TaskStatus

image

Another way to work more elegant with SPListItems is using the SPListItemCollection.GetDataTable() method.

$list.Items.GetDataTable() | group-by TaskStatus

The downside of this approach could be that it allocates more memory, usually that doesn't matter. I've found this approach on Jesper M. Christensen's blog - thanks.

Sep 25, 2008

Interview PowerActivity with MVP Michael Greth

Here is an inteview about my PowerActivity with MVP Michael Greth (on German, flavoured with "saarländisch"). Rhetorical lousy, but with a lot of passion ;-)


Thanks Michael.


Auf die Pole Position mit Data One

Data One, Microsoft und HP machen Ihr Unternehmen fit für die Pole Position! Damit auch Sie zukünftig Bodenwellen und rutschigen Asphalt umgehen können, zeigen wir Ihnen den richtigen Weg für Ihren Unternehmenserfolg und zukünftige Potenziale

Wie das geht? Ganz einfach: Wir laden Sie ein, sich im Rahmen einer Nachmittagsveranstaltung von den Vorzügen des neuen 2007 Microsoft Office Systems überzeugen zu lassen.

Erleben Sie praxisorientierte und innovative Vorträge von Data One, Microsoft und unseren Kunden. Nutzen Sie die Möglichkeit, an unseren Infopoints mehr über die neue Welt der Microsoft-Software und die Hardwarelösungen von HP für Ihr Unternehmen zu erfahren. Seien Sie immer eine Reifenlänge voraus!

Renntag:
06. November 2008

Startzeit:
13:00 Uhr

Zieleinlauf:
17:45 Uhr

Rennstrecke:
Parkhotel Albrecht, Völklingen

Detaillierte Informationen zur Agenda entnehmen Sie bitte dem Flyer zur Veranstaltung.

Als Special erwartet Sie eine exklusive Auswahl an sportlichen Fahrzeugen unseres Sponsors Audi, mit denen Sie Ihr Können auch mal außerhalb des Büros unter Beweis stellen können.

Sie wollen den Start in eine erfolgreiche Saison nicht verpassen? Kein Problem - melden Sie sich noch heute online an.

Wir freuen uns auf einen siegreichen Renntag mit Ihnen!

Sep 23, 2008

SOON: PowerWebPart

Hey PowerGuys, actually I'm working on the PowerWebPart and maybe I'll release it this week.

Features:

  • Simple HTML Rendering
  • Using ASP.NET and SharePoint Controls
  • Receive ASP.NET Events
  • Runas Current User or Application Pool User
  • Parameters
  • Saving the WebPart as Template and reuse it
  • Security: Only Site Administrators can change the script, other users can only change the parameters
  • WebPart Connections: Table-Provider, Table Consumer, Row Provider, Row Consumer
  • Everything PowerShell can do!

Screenshots:

  • Simple HTML-Rendering (get-process)

image

image

image


  • Dynamic ASP.NET Controls + Event Receiving
image 
 
image 


  • Use SharePoint Controls and Objects and Parameters

image


Use a parameter for the list title


image


image

Any suggestions?

Sep 13, 2008

SharePoint, Workflows and Security

If you are going to develop SharePoint workflows either with Visual Studio or SharePoint Designer you will have to think about security - regardless you want or not.

The most important thing is knowing the windows identity under which your activity will run on SharePoint. That's either the IIS application pool user, in case you stimulate the workflow via the web interface or the Windows SharePoint Services Timer user for scheduled stimulations. The workflow operates with the system privileges of its windows identity. This behavior is the same for both Visual Studio and SharePoint Designer workflows.

Because SharePoint has a security model of its own the windows identity doesn't matter! The granted SharePoint privileges depends on the current SPUser. In case of a Visual Studio workflow the SPUser get from the SPWorkflowActivationProperties' objects is the the SHAREPOINT\system user with full SharePoint privileges.

SharePoint Designer workflows behaves another way. The current SPUser get from the WorkflowContext's objects (e.g. WorkflowContext.Site) is impersonated to the workflow's author, the user who started the workflow. Means the workflow operates with the SharePoint privileges of the author (usually contributor rights) and the system privileges of the windows identity (Application Pool/Timer Service user)!

Impersonation snippet taken out of the WorkflowContext.Site property:

SPSite site = new SPSite(this.m_siteId);
SPUser user = site.RootWeb.SiteUsers[this.m_inProps.Originator];
SPUserToken userToken = user.UserToken;
this.m_site = new SPSite(site.ID, site.Zone, userToken);
site.Close();
 
If you write a custom activity for SharePoint Designer as described here, you may want to undo this impersonation. You can use the following code snippet in the activities' execution context to undo:

SPSite site = new SPSite(__Context.Site.ID));
SPWeb web = site.AllWebs[__Context.Web.ID]);

You don't need to use the SPSecurity.RunWithElevatedPrivileges method because the current windows identity is the application pool user.  
Now the site and the web run with the SharePoint system user's privileges.
 
Bye, Christian
 

Sep 10, 2008

Call a Web Service with SharePoint Designer and PowerActivity

WARNING EXPLICIT SCRIPTS: The example is quiet complex!

  • Create a custom list "Power Snippets"
  • Add a multiple line plain text column, perhaps 60 lines, "PSScript"
  • Define any other list to attach the workflow (Title, Result as Rich Text)
  • Add your snippets to the list (e.g. my Get-WebServiceProxy script (Requirements for this script: Windows SDK (wsdl.exe) and .NET 3.5. )

image

image 

  • Use the snippet in SharePoint Designer. Add the "Execute PowerShell Activity to your SPD Workflow. Define a workflow variable named "result" type of text to store the result of the web service request. Insert the following script:

image

  • The [%Power Snippets:PSScript%] is a lookup to our Get-WebServiceProxy script snippet. The lookup makes the Get-WebServiceProxy function available to our script. The lookup is something like an old school PHP-include ;-)image
  • The script bellow the lookup generates a proxy for the SharePoint Lists.asmx webservice, call the GetListCollection method, generates from the response an HTML string containing a bullet list.
  • In the next step we set the "Result" column to the "result" variable we filled before with PowerActivity.

image

  • Save and start the workflow...image
  • :-)

Another way to call a web service with the PowerActivity would be to create the proxy with or Visual Studio wsdl.exe, compile and deploy the assembly to the global assembly cache of the server. Now you can load the assembly in PowerShell like [System.Reflection.Assembly]::Load... and instantiate the proxy New-Object -TypeName... This solution is faster and you don't need the WinSDK on the server.

Any questions?

Bye,Christian

Use PowerActivity to Be...

...a bad boy and shutdown your bosses' computer ;-)

shutdown /s /f /m \\computerNameOfYourBoss

image Really useful ;-)

Christian