Feb 22, 2011

PowerActivity 2010 (Advanced SharePoint Designer 2010 Workflow Actions)

I’m glad to announce that I’ve just added the “Execute PowerShell Script” action (aka PowerActivity 2010) to the latest build of Advanced SharePoint Designer 2010 Workflow Actions.

Add “Execute PowerShell Script” action to a SharePoint Designer Workflow

image

Configuration

image

Script

The PowerShell script to execute. You can use the following predefined variables:

  • $site = the current Microft.SharePoint.SPSite
  • $web = the current Microft.SharePoint.SPWeb
  • $list = the current Microft.SharePoint.SPList (null in site workflows)
  • $item= the current Microft.SharePoint.SPListItem (null in site workflows)
  • $ctx = the current workflow context Microsoft.SharePoint.WorkflowActions.WorkflowContext
  • $sharePointService = the current Microsoft.SharePoint.Workflow.ISharePointService service
  • $listItemService = the curent Microsoft.SharePoint.Workflow.IListItemService service

The process will run as system account. However, by default $site and $web will run as the current workflow initiator or author (impersonation step). When you want to impersonate the site to the system account create a site like this: $impersonatedSite = new-object Microsoft.SharePoint.SPSite($site.Id).

Avoid the usage of the SharePoint Designer Text Editor tokens in the script, because of the potential risk for script injection attacks. Instead use variable binding ($var1, $var2…)

Signature

By default every script you that want to execute must be digitally signed. However, you can change the setting to not require a digital signature (dev system). The corresponding PowerShell script is included in package.

Disable Script Signing

The script must run on a SharePoint machine

PS> & .\Set-PowerActivityScriptSigning.ps1 $false

Sign Scripts

In order to sign scripts you need the private key that has been generated during the installation of solution.

1. Export Private Key

The script must run on a SharePoint machine. Keep the private key secure.

PS> & .\Export-Key.ps1 –path “C:\private.key” –includePrivateKey $true

2. Sign the Script

After you have exported the private key you can sign the script. The signing must not be done on a SharePoint machine, you only need the private key and the script. To sign the script you have to save it temporarily to a file.

PS> & .\Sign-PowerActivityScript.ps1 –keyPath “C:\private.key” –scriptPath “C:\script.ps1”

The signature will look like this:


YoVKP2lCKF1B8Q9ZIBvy98+T2haNayr81aGTfXEPyRmFxLNII3R6pagaHVZfZ7j5L2zTga53SqetVRLgTUebiOan2WUnCR2HualqvvdXYX1LhwAZ/Kda
OibqpE5aGgZTesJJln8+81Qwy4wOqSxCv3iQjIgVbJz7+D3kIm9dP7Q=

Simply copy & paste the script and the signature to the script and signature field of the “Execute PowerShell Script” action.

White spaces in the script will be ignored in the signing process.

$var1, $var2, $var3, $var4, $var5

You can bind PowerShell variables ($var1, $var2…) to workflow variables.

$web.Title = $var1

$web.Update()

The binding is two way, this means you can change the workflow variables in the script.

$var2 = “my value”

$secure

$secure is a special variable that can contain an encrypted string that will be decrypted during runtime. You could use this variable to securely store a password. The binding ot this variable is one way, means you can not set the value in the script during runtime. For how to encrypt strings read this.

Secure Store AppId

The Secure Store App have to define 2 Fields. One of type “User Name” and one of type “Password”. The Field Name doesn’t matter, important is the Field Type! You have to map the credentials of the SharePoint Service Accounts (AppPool/owstimer.exe). The secure store option will only works with SharePoint Server, not with Foundation! You can access the credentials during runtime with the $credential variable (System.Net.NetworkCredentials).

Wiki Documentation

28 comments:

John said...

I tried this on my test server, the pre-built VHD from MS. I duuno what im doing wrong, but I get an error saying: Object reference not set to an instance of the object. Any idea why I get this error?

Brian said...

I'm getting the same error. My workflow is very simple for testing and does the following:

Set Variable:test to "Stuff"
Execute Powershell: $var1="Junk" ($var1:Variable:test)

The workflow errors with : "Error while executing PowerShell Script: Object reference not set to an instance of an object."

I'm stumpted on what I could be doing wrong here.

Christian said...

Brian, thanks for your feedback! Should be fixed in build 71729. The issue was that the "secure string" parameter had to have a non empty value.
Bye, Christian

Andy V. said...

the guys do the same but for money: harepoint workflow extensions. There is execution of Power Shell scripts, SQL Commands etc. I am using harepoint extensions because I can export my workflows to Visio and import it back to SPD.

electronic signature software said...

Very helpful article ! I was always curious about all these complex algorithms that are being used in these ssl encryptions.

MelviN said...

Error while executing PowerShell Script: Unable to get credentials for application PShell

wei coco said...

Louis Vuitton Damier Canvas Duomo N60008 Today, I wish to acquaint the Louis Vuitton Damier
Canvas Duomo N60008,it is a all-encompassing Italian appellation for a basilica church, acceptation house. This season, Louis Vuitton handbags launched a city-limits bag called from this celebrated arcade commune in Florence, Italy. It is replica watches N60008. If you accede acutely what the accord amid the Duomo of Florence and Louis Vuitton Duomo, I anticipate it is adorableness and fame. The Duomo of Florence is accustomed as the Gates of Paradise. You will be addled by its blush and louis vuitton replica affluent apery of the exterior, and its amplitude and the abnegation of the autogenous furnishings. The Duomo of Florence was congenital with accessible funds as a accompaniment church, and important works of art in the ancillary aisles aggregate a borough affairs anniversary illustrious men. That is just what gucci replica wants to accord us. The awe-inspiring Damier canvas, the superior craftsmanship, and the agleam golden assumption pieces, aggregate is so absorbing and superlative. The comfortable contour firstly gives humans actual comforts. Then the red bolt lining , autogenous louis vuitton handbags replica flat abridged and cellphone abridged accompany barter majestic activity and anatomic using. To imitate the best style, replica shoes matches a aureate padlock with keys captivated on amber leather. Each detail architecture alluringly and considerately.






Hug Day said...

happy hug day 2016
happy hug day 2016 Date SMS Messages Quotes
Hug day Celebration Ideas
hug day sms for bf/gf

风骚达哥 said...

20160423 junda
air jordans
cheap oakley sunglasses
kate spade outlet
adidas stan smith
ray ban sunglasses
michael kors outlet
nike air max shoes
cheap omega watches
yeezy boost 350
michael kors outlet online
michael kors outlet online
nike free runs
air jordan uk
michael kors outlet online
pandora charms
ray ban outlet
calvin klein outlet
fitflops sale clearance
toms outlet
nike huarache white
sac longchamp
toms outlet
michael kors outlet clearance
bottega veneta outlet
armani watches
gucci handbags
nike blazer
oakley sunglasses
true religion jeans
cheap jordans
ray bans
hollister
bottega veneta handbags
jimmy choo outlet
oakley sunglasses
converse
prada outlet
reebok shoes
true religion
burberry outlet

Desty Lilian Rosana Putry said...

model meja belajar anak minimalis
warna cat rumah minimalis
model rak tv
model meja makan
taman kolam air
model pintu kamar mandi
model tangga rumah minimalis
warna cat pagar
desain tiang dan keramik teras
kursi sofa ruang tamu minimalis
model tempat tidur bayi
warna cat dapur
model atap rumah minimalis
model plafon minimalis
warna gorden ruang tamu
warna cat rumah tipe 45
model rumah idaman type 36

Libin Huang said...

20160426libinferragamo outlet
pandora outlet
ferragamo shoes
nike air max
ferragamo shoes
hermes belt for sale
michael kors factory outlet
swarovski crystal
ferragamo shoes
michael kors outlet
louis vuitton handbags
louis vuitton handbags outlet
swarovski outlet
beats by dre
cazal outlet
mont blanc pens
longchamp solde
fitflops outlet
cartier sunglasses for men
michael kors outlet
louis vuitton outlet
swarovski crystal
cheap nfl jerseys
adidas outlet store
tory burch outlet
cheap oakley sunglasses
mulberry bags
rolex watches,rolex watches,swiss watches,watches for men,watches for women,omega watches,replica watches,rolex watches for sale,rolex replica,rolex watch,cartier watches,rolex submariner,fake rolex,rolex replica watches,replica rolex
oakley sunglasses
tory burch outlet
ray ban sunglasses
louis vuitton outlet
polo ralph lauren
michael kors uk
tiffany outlet

Yuanyuan Lin said...

7.14llllllyuan"hollister shirts"
"true religion canada"
"true religion outlet"
"beats by dre"
"nike tn pas cher"
"ray ban sunglasses"
"tory burch outlet"
"mulberry handbags"
"prada outlet"
"michael kors outlet"
"tiffany outlet"
"louis vuitton neverfull"
"louis vuitton handbags"
"giuseppe zanotti shoes"
"nike uk store"
"michael kors wholesale"
"tiffany jewelry"
"michael kors outlet"
"ralph lauren pas cher"
"mulberry bags"
"nike air force 1"
"police sunglasses for men"
"gucci outlet online"
"ray ban sunglasses"
"jordan shoes"
"asics,asics israel,asics shoes,asics running shoes,asics israel,asics gel,asics running,asics gel nimbus,asics gel kayano"
"cheap jordan shoes"
"basketball shoes"
"fitflops sale"
"prada outlet online"
"ralph lauren polo"
"nike air max 90"
"omega outlet"
"lacoste shirts"
"longchamp outlet"
7.14

Fangyaya said...

michael kors handbags
coach factory outlet online
ghd flat iron
louis vuitton handbags
ralph lauren
polo shirts
ray ban sonnenbrille
nfl jerseys wholesale
kate spade outlet
ray ban sunglasses
coach outlet online
coach outlet online
louis vuitton outlet stores
christian louboutin sale
giuseppe zanotti sneakers
cheap ray ban sunglasses
michael kors outlet clearance
louboutin shoes
air jordan shoes
tods sale
replica rolex watches
coach outlet
coach outlet store online
louis vuitton outlet stores
coach outlet store online clearances
adidas yeezy
tory burch flats
polo ralph lauren
coach outlet store online clearances
air jordan 11
20168.8chenjinyan

jocelyn said...

angry birds 2 cheats iphone
angry birds 2 cheats iphone
angry birds 2 hack tool
angry birds 2 hack tool
angry birds 2 hack no jailbreak
angry birds 2 hack tool
angry birds 2 hack tool
angry birds 2 hack tool
angry birds 2 hack tool
angry birds 2 hack tool
angry birds 2 hack tool
angry birds 2 hack tool
angry birds 2 hack no jailbreak
angry birds 2 hack tool
angry birds 2 hack tool
angry birds 2 hack tool
angry birds 2 hack tool
angry birds 2 hack no jailbreak
angry birds 2 hack tool
angry birds 2 hack tool
angry birds 2 hack tool
angry birds 2 hack tool
angry birds 2 hack no jailbreak

dada24 Xu said...

cheap oakleys
ralph lauren pas cher
canada goose
michael kors outlet clearance
true religion outlet
armani exchange
gucci outlet
ed hardy
ugg boots
ray ban sunglasses
2016921caiyan

Paulo said...

The financial record and score are enormous effect by a few distinct things, where in the length of record as a consumer of a borrower, proportion of their obligation to pay and quantities of reprobate records. Spending times repairing any negative imprints may help and can spare a large number of dollars in spite of the fact that it's tedious however it is incredible toward the end. Payday Loans Chicago

Paulo said...

In Mobile Home Parks, the administrator typically just keeps up the regular regions and the inhabitants keep up their own spaces, and so on. In any case, in a RV Park, the director won't just keep up the normal territories, however ought to check every space to ensure it is perfect before leasing. cash advance san-diego

Gracey said...
This comment has been removed by the author.
jeffrey said...

google play gift card balance
google play gift card codes hack
fake google play gift card codes that work
free google play gift card codes android
google play gift card uk
google play gift card codes app
google play gift card codes list
google play gift card uk
google play gift card codes app
google play gift card balance
google play gift card uk
google play gift card codes list
google play gift card codes south africa
google play gift card balance
google play gift card balance
google play gift card codes app
free google play gift card codes app
free google play gift card codes android
google play gift card codes south africa
google play gift card codes app
free google play gift card codes app

Robbert said...

These bundles are similarly less expensive than purchasing each of the administrations independently. In this manner taking after the given direction you can make trip of Italy pleasant contracting auto renal administrations. Cash Advance

Robbert said...

In 1978, build David Arthurs created what might turn into a pillar of cutting edge half and half innovation, the regenerative breaking framework. This framework permits half breed autos to change over a piece of their motor (vitality of movement) into power, which is then put away in their batteries. Along these lines, a half breed auto can preserve power, and utilize vitality all the more effectively. Cash Advance

Robbert said...

Oil stocks adrift and ashore are still accepted to be genuinely abundant. The inconvenience is it is costing increasingly to concentrate this incredible asset. The stark truth is that in 50 years time petroleum will probably be costing 20 times what it does today.
check cashing

Teresa Hamilton said...

It's so hard to learn it myself. Thank you very much for sharing!!
instagram online

huali10 Cai said...

rolex watches for sale
louis vuitton
cheap jordans for sale
air max 90
longchamp outlet
nike outlet store online
tory burch outlet online
futbol baratas
cheap oakley sunglasses
michael kors outlet clearance
qqqqqing20170411

Unknown said...

cartier outlet
fitflops sale clearance
sac louis vuitton pas cher
longchamp outlet online
mulberry uk
thomas sabo charms
cheap oakley sunglasses
cheap nike shoes
ray-ban sunglasses
ralph lauren
chanyuan2017.05.08

xjd7410@gmail.com said...

polo ralph lauren outlet
michael kors handbags
mlb jerseys
cheap nfl jerseys
asics,asics israel,asics shoes,asics running shoes,asics israel,asics gel,asics running,asics gel nimbus,asics gel kayano
foamposite shoes
louis vuitton outlet
chrome hearts
oakley sunglasses sale
fitflops uk
chanyuan2017.05.24

شركة المثالية لتنظيف said...

شركة تنظيف منازل بالاحساء

raybanoutlet001 said...

ferragamo outlet
polo ralph lauren outlet
ugg boots
ugg outlet
ugg boots
nike huarache
supra sneakers
cleveland cavaliers jerseys
jacksonville jaguars jersey
snapbacks wholesale