Jul 2, 2008

SharePoint Designer PowerShell Activity

The first Code I've published on i Love SharePoint is the SharePoint Designer PowerShell Activity. Anything PowerShell can do, anything the Activity can do - that's really a lot!

Quick Start (Installation see ReadMe.txt):

  • The example creates a new Site based on the Workflow's List Item Title.
  • Add the Activity to a SharePoint Designer Workflow



  • Insert the following PowerShell Script:


    $web.Webs.Add($item.ID.ToString(),$item.Title,"Created by PowerShell",1031,"STS#0",$false,$false);

    $web.Dispose();

  • Save
  • Run the Workflow. The Workflow now creates a Site named like the List Item. The URL of the Site will be the ID of the Item.

That's just one trivial example. Any ideas how to use, please tell me...

Quick Reference:

In your PowerShell Script you can use the following Variables:

  • $site = current SPSite
  • $web = current SPWeb
  • $list = the List of the Workflow SPList
  • $item = the SPListItem of the Workflow
  • $variable1 = the Workflow Variable you defined for Variable1 in the SharePoint Designer (=$null if you have not defined)
  • $variable2 = the Workflow Variable you defined for Variable1 in the SharePoint Designer (=$null if you have not defined)

You can set the two Workflow Variables within the Script through returning a Hashtable
(keep care on correct types)= @{"variable1"="my Value1";"variable2"=4711};

Errors could be found in the Event Log.

WARNING: This Activity might cause huge security vulnerabilities!

Any comments would be appreciated.

58 comments:

Chanda said...

Christian,

Thanks for the great custom SPD activity! I'm new to PowerShell so maybe that's where I'm running into an issue and I'm wondering if you could help. I'm using v1.2.

I have installed the solution and it's accessible in SPD, however I think I just can't get the syntax correct. I am trying to perform a substring function in order to get the portion of a string after a specific character (#).

The script I'm using in the SPD activity is:

@{"variable1"=[%Variable: MyVar%];
$Index = $variable1.IndexOf('#');
$variable1.Substring($Index);

When I run the workflow it errors and the workflow history reports "Error Executing PowerShell Script. Missing '=' operator after key in hash literal."

If I try to assign static text to variable1:

@{"variable1"="8;#John Smith";
$Index = $variable1.IndexOf('#');
$variable1.Substring($Index);

the workflow also errors and the workflow history reports "Error Executing PowerShell Script. You cannot call a method on a null-valued expression."

Is there something I've gotten wrong with the syntax?

Thanks!
Chanda

Chanda said...

Christian,

I've made some progress, now the workflow completes successfully using the following script and I get "John Smith" as a result:

$a = "8;#John Smith";
$index = #a.IndexOf("#");
$output = $a.Substring($index + 1);

The issue I am running into now is that if I attempt to use a workflow variable instead of static text the workflow errors and the workflow history reports "Error Executing PowerShell Script. Method invocation failed because [System.Int32] doesn't contain a method named 'IndexOf'."

Here is the script I'm using now:

$a = [%Variable: Name%];
$index = #a.IndexOf("#");
$output = $a.Substring($index + 1);

Any instructions on how to use workflow variables within the PowerActivity string builder?

Thanks again,
Chanda

Chanda said...

Christian,

I've made some progress, now the workflow completes successfully using the following script and I get "John Smith" as a result:

$a = "8;#John Smith";
$index = #a.IndexOf("#");
$output = $a.Substring($index + 1);

The issue I am running into now is that if I attempt to use a workflow variable instead of static text the workflow errors and the workflow history reports "Error Executing PowerShell Script. Method invocation failed because [System.Int32] doesn't contain a method named 'IndexOf'."

Here is the script I'm using now:

$a = [%Variable: Name%];
$index = #a.IndexOf("#");
$output = $a.Substring($index + 1);

Any instructions on how to use workflow variables within the PowerActivity string builder?

Thanks again,
Chanda

Chanda said...

Christian,

I've made some progress, now the workflow completes successfully using the following script and I get "John Smith" as a result:

$a = "8;#John Smith";
$index = #a.IndexOf("#");
$output = $a.Substring($index + 1);

The issue I am running into now is that if I attempt to use a workflow variable instead of static text the workflow errors and the workflow history reports "Error Executing PowerShell Script. Method invocation failed because [System.Int32] doesn't contain a method named 'IndexOf'."

Here is the script I'm using now:

$a = [%Variable: Name%];
$index = #a.IndexOf("#");
$output = $a.Substring($index + 1);

Any instructions on how to use workflow variables within the PowerActivity string builder?

Thanks again,
Chanda

Chanda said...
This comment has been removed by the author.
Christian said...

Chanda,

simply surround the [%Variable: Name%] with quotes: "[%Variable: Name%]". So it will be interpreted as a string.
Bye, Christian

Sascha said...

Christian,
Great SPD Add-On.

Just my problem: we host a shared solution for my company where some developers would be so thankfull for this tool. But can I restrict the usage? Otherwise anyone with access to SDP and with the ownership on some site would be able to play havoc on the farm....

-Sascha

Christian said...

Thanks Sascha, unfortunatley you can't limit the usage at the site level. Only per web app (web.config). SharePoint designer doesn't allow custom designers :( We use Nintex with our PowerActivity http://www.dataone.de/en/solutions/sharepointportals/Seiten/NintexWorkflowPowerActivity.aspx. This Activity can only be used by Farm Admins and the scripts will be autatically digital signed. I hope the SharePoint Designer will allow such scenarios in the future too. At the moment it doesnt't look good.
Bye, Christian

Sascha said...

Hi,
thanks for the fast answer. Bad news...

Would it be a solution to make a spinoff of your SPD activity which would take the filename of a local ps1 script instead of the code? This would make it possible to deploy only certified (and/or signed) scripts directly to the SharePoint server... Unsigned code on the dev box, signed code on the prod system....

-Sascha

Xj Cheng said...

Replica Handbags: Amount & Superior Consciousness!Our handmade Replica accoutrements are absolute artist delights consummate accessories for gucci replica the appearance conscious,at a atom of the amount of an aboriginal artist handbag.You could buy a Versace replica backpack for anniversary day of the anniversary for the amount of one aboriginal Versace handbag.Afar from you and Beubag.com,no one abroad will apperceive that your Versace replica backpack is louis vuitton replica a replica and not the actual original!From the aboriginal canicule to the present day the backpack is still a actualization icon,and over time the styles accept afflicted but accustomed a backpack still agency fashion.Most able who abrasion these Rolex replica watches accept accepted that they accept begin a new angel of themselves afterwards they accept started cutting these Rolex replica watches!So what are you cat-and-mouse for? Get one of the endless models of cartier replica the Rolex replica watches and see your activity change immediately.Not alone will the girls at the affair battery all their amore on you,you can be blow assured that even your bang-up will pay appropriate absorption at you.Rolex replica watches accomplish these wonders and lots more.Swiss replica watches are acclaimed all over their apple for their body and accomplish and you can acquisition a lot of celebrities cutting them and assuming off that they are anyone special.They wish to get the best out of activity for the least.Swiss replica watches provides them with an befalling to appearance off replica watches uk what is declared to be the best for the minimum cost.

Hug Day said...

hug day 2016 Images
happy hug day 2016 Date SMS Messages Quotes
Hug day Celebration Ideas For Him/Her
hug day sms for 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

Libin Huang said...

20160426libinhollister clothing store
oakley sunglasses
michael kors handbags
tiffany outlet
ray-ban sunglasses
gucci outlet online
ray-ban sunglasses
burberry outlet online
coach outlet canada
ray-ban sunglasses
herve leger outlet
ray ban sunglasses sale
air max 90
oakley sunglasses
adidas wings shoes
michael kors outlet
michael kors factory outlet
louis vuitton bags
michael kors online outlet
nba jerseys
ralph lauren pas cher
oakley sunglasses
toms shoes
nike air max 90
nike tn pas cher
air max 90
lululemon outlet
nike air force 1
true religion outlet
michael kors outlet
burberry outlet store
ray ban sunglasses
kobe shoes
true religion outlet
discount michael kors handbags

Yuanyuan Lin said...

7.14llllllyuan"ferragamo shoes"
"chrome hearts outlet"
"air jordan shoes for sale"
"tory burch outlet online"
"hollister"
"michael kors outlet"
"ralph lauren femme"
"thomas sabo uk"
"adidas uk store"
"louis vuitton outlet"
"coach outlet"
"coach handbags"
"burberry outlet"
"coach outlet online"
"rolex watches"
"cheap oakley sunglasses"
"tiffany outlet"
"cheap football shirts"
"celine outlet online"
"michael kors handbags clearance"
"snapbacks wholesale"
"michael kors outlet"
"toms outlet store"
"true religion outlet uk"
"coach outlet store"
"oakley sunglasses"
"celine outlet"
"swarovski outlet"
"cheap snapbacks"
"longchamp pas cher"
"michael kors outlet online"
"fitflops clearance"
"nike roshe run"
"coach outlet online"
"oakley sunglasses"
7.14

Fangyaya said...

nike roshe one
cheap oakley sunglasses
cheap oakleys
michael kors bags
coach outlet store online
retro jordan shoes
louis vuitton purses
coach outlet online
coach factory outlet
burberry sale
red bottom shoes
michael kors handbags
retro 11
coach factory outlet
louis vuitton outlet
louis vuitton
ghd hair straighteners
louis vuitton handbags
coach outlet
ralph lauren outlet
coach factory outlet online
cheap ray ban sunglasses
true religion jeans
louis vuitton bags
ray ban sunglasses outlet
cheap ray ban sunglasses
longchamp outlet
coach outlet online
ralph lauren
gucci belts
ray ban outlet
ray ban outlet
michael kors handbags
fitflop shoes
coach outlet clearance
montblanc pens
toms shoes uk
ralph lauren clearance outlet
timberlands
retro jordans 13
20168.8chenjinyan

Robbert said...

It is the obligation of the undergrad to ascertain the advance sum required by him/her with exactness and afterward apply for the most appropriate utilized vehicle advance accessible. The understudy might however remember the extra costs like protection, repairs, and so on that may come up in the long run. check cashing

Justin said...

A private understudy advance is a choice that you can get in the event that you don't have any significant bearing for a government advance. There are numerous private moneylenders with fabulous projects for graduate credits. payday loans chicago

dada24 Xu said...

ysl outlet online
jordan shoes
vans outlet store
uggs sale
vans shoes
michael kors outlet
birkenstocks
ugg australia
borse gucci
celine outlet
2016921caiyan

chenlina said...

chenlina20160923
mont blanc pens
louis vuitton outlet
uggs australia
uggs on sale
adidas trainers
longchamp outlet
nike roshe run
ralph lauren
adidas shoes
coach outlet store online clearances

John said...

air force 1
birkenstock outlet
ugg sale
fitflops sale
michael kors outlet store
canada goose jackets
nike uk
converse all star
ralph lauren outlet online
coach outlet online
birkenstock outlet
abercrombie
polo ralph lauren outlet
adidas nmd r1
mcm outlet online
coach outlet online
timberland boots outlet
ed hardy store
true religion jeans outlet
nike cortez classic
timberland shoes
louis vuitton outlet online
birkenstock sale
louboutin outlet
michael kors handbags outlet
uggs sale
birkin handbags
rolex watches for sale
michael kors outlet store
vans outlet
polo ralph lauren outlet online
20161102yuanyuan

Meiqing Xu said...

armani exchange
cheap nike shoes
coach outlet
ugg boots canada
kd 9 shoes
christian louboutin sale
michael kors outlet
moncler outlet
uggs
yeezy 350 boost
20161221caiyan

chenmeinv0 said...

michael kors handbags
polo outlet
timberland outlet
le coq sportif shoes
oakley sunglasses
nike roshe
air jordan pas cher
michael kors handbags
ray ban sunglasses
michael kors
hzx20170228

chenmeinv0 said...

louis vuitton
true religion outlet
michael kors outlet online sale
ray ban sunglasses
ray ban sunglasses
louis vuitton
adidas nmd
adidas outlet
michael kors outlet
dallas mavericks jerseys
hzx20170228

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

dong dong23 said...

coach outlet store online clearances
hermes outlet
supra outlet
mont blanc mountain pen
mlb jerseys cheap
true religion outlet
kobe 9 shoes
fred perry polo shirts
christian louboutin heels
michael kors outlet
2017.5.11chenlixiang

Home Improvement City of Yonkers said...

The team at Ajrin Construction Inc. is the best of the best general contractors and support staffs, as selected from within the industries over City of Yonkers NY based upon their achievements and their understanding of complex projects.Best Home Improvement Company City of Yonkers

洛噷 said...

2018120 leilei3915
michael kors outlet online
true religion outlet online
vintage nhl jerseys
mulberry handbags
uggs outlet
coach outlet
adidas superstar shoes
jordan retro shoes
michael kors outlet
cheap ugg boots

khairy said...

شركة عزل اسطح بالمدينة المنورة
شركة تسليك مجاري بالمدينة المنورة
شركة تنظيف وصيانة مسابح بالمدينة المنورة
شركة تنظيف الاثاث بالمدينة المنورة
شركة تنظيف ستائر بالمدينة المنورة
شركة جلي بلاط بالمدينة المنورة
شركة تنظيف مساجد بالمدينة المنورة

scott april said...

www.office.com/setup
Awesome! It's really awesome piece of writing, I have got much clear idea concerning from this article.
www.office.com/setup

raybanoutlet001 said...

zzzzz2018.5.9
nike shoes
ralph lauren uk
red bottom
coach outlet
ralph lauren uk
coach factory outlet
coach outlet
jordan 4
coach outlet store online
chrome hearts

chenlili said...

pandora charms
coach outlet store online
ferragamo outlet store
ray-ban sunglasses
christian louboutin shoes
longchamp handbags
pandora charms outlet
fitflops sale clearance
fred perry polo
coach outlet online
yaoxuemei20180528

洛噷 said...

2018914 leilei3915
fred perry shirts
ugg outlet online clearance
canada goose outlet
coach outlet online
polo ralph lauren outlet
nfl jerseys wholesale
ray ban pas cher
canada goose outlet
christian louboutin outlet
michael kors outlet

aol mail said...

www.office.com/setup
Learn, how to download and setup Microsoft office software For Windows and Mac OS PC/Laptop

Margie Brooks said...

Background Removal Services (BRS) is one of the best Clipping path service provider around the world. We offer our global customers: Raster to Vector Services, Photo Restoration Services Prices, Photo Neck Joint Service, Exposure Color Correction Service, Jewelry Photo, Retouching Services, Photo Color Correction Service, Image Mirror Effect Service, Cheap Retouching Services, Deep Etching Service,

Product Items said...

Product Items Is a Product Review Website. Here We Reviewed Best Product. If You Want to Buy Any Product, You Need to Read Product Features, Product Details, Product Description, Product Specification, Product Ratting, Pros and Cons. If You Want to Learn More Product Review Visit our Product Items Website.

5689 said...

zzzzz2018.11.15
coach handbags
ugg outlet boots
true religion jeans
ugg outlet
ugg boots outlet
jordans
vibram five fingers
ralph lauren polo
michael kors outlet
ralph lauren uk

Pets Ability said...

Petsability is the Best Online Pet Medicine Company. You can find Best joint supplements for dogs, probiotics for cats, cat separation anxiety, dog calming spray, pet vitamins and supplements, hip and joint supplements for dogs, Natural Medicines for Anxiety, Joint Pain, Digestion, and Kidney failure for Dogs & Cats. Shop Now

List Forever said...

ListForever – Never Ending Show Starts Here. Guys it is a place for some of really interesting, fascinating and knowledgeable lists like; Fastest car, Fastest bike, Fastest train, Fastest animal, Most expensive watch, Most expensive hotel, Tallest building, Hottest women, Most expensive shoes, Highest paid actor, Most powerful military, Most powerful people in the world, Hottest actress in Hollywood, Most beautiful Italian women, Most beautiful British actress, Highest grossing movie of all time, Best Bollywood movie of all time, Foods that can kill you. We are here with some cool lists, after reading it shall definitely update you with interesting trivia.

Probiotics for Cats said...

How do you know if you should give your cat probiotics? What kind of probiotics should you buy for your cat and how often should you administer them? petMD reached out to an array of experts who have studied the topic to find out more about probiotics for cats.

Joint Supplements for Dogs said...

Our select Joint Supplements for Dogs Glucosamine, Chondroitin and Turmeric formula works to not only relieve pain, ease limb heaviness and joint aches but also lubricates joints and strengthens cartilage to increase your pets mobility and greatly improve their quality of life Relieves stiffness and inflammation in pets sufferin

j joody said...


Thank you very nice
https://www.rashed-kw.com/ادوات-صحية-الكويت/
https://www.rashed-kw.com/معلم-صحي-بالكويت/
https://www.rashed-kw.com/نقل-عفش-السالمية/
طريقة تحريك الكنبة
https://www.rashed-kw.com/نقل-عفش-حولي/
https://www.rashed-kw.com/نقل-عفش-المنطقة-العاشرة/

Jovani said...

Stardust Boutique is a Jovani prom dresses company. If you are looking for a prom dress, we are a Jovani dress store and stockist supplying UK, USA, Canada, Australia, internationally.We stock all kinds of Jovani if you want a Jovani prom dresses, Jovani short dress, Jovani evening dress, Jovani pageant dress, jvn prom dress, jvn short dress and pageant dresses.

Fastest Car said...

If you want to Fastest Car In The World. you can visit listforever.com here you will get Top 30 Fastest Cars in The World | Pictures, Price and Specifications.

chandan kumar said...

Install Office Setup – Sign-in to you microsoft account and then Enter 25 digit alphanumeric office setup product key on country and language.click on next to start office installation.We are the best Office Setup in US, Canada and Australia. www.office.com/setup

Fastest bike in the world said...

if you want to know Fastest Bikes in the World. you can visit listforever.com. Here you will get Top 12 Fastest Bikes in The World | Pictures, Price and Specifications

Weber Guide said...

WeberGuide is a product reviewing and informative website that provides a fruitful guide in before and after buying all the accessories. We Publish Information about Home Accessories, Sports, Outdoor and Gardening. Visit our website to see our latest article on Best Kukri Knife, Best Flushing Toilet, Best Air Mattress and so on. For the most part, there are numerous sorts of sites on the web about the best items. In any case, we locate that the greater part of these are ecommerce site where individuals are simply attempting to offer their items. In any case, here on this site, you will get bunches of data which will spare your significant time and help you to pick the best items.

Aafesh Transport said...

شركة نقل عفش بجدة , شركة نقل اثاث بجدة ,شركات نقل العفش بجدة , شركات نقل الاثاث بجدة, افضل شركة نقل عفش بجدة , افضل شركة نقل اثاث بجدة , نقل عفش بجدة ,نقل اثاث بجدة ’ ارخص شركة نقل عفش بجدة ,ارخص شركة نقل اثاث بجدة , نقل عفش بجدة رخيص , شركة , شركات ’ جدة , عفش , اثاث , افضل , ارخص , سيارات , رقم , ارقام , دليل , مؤسسة , مؤسسة نقل عفش بجدة , ديانا , , اضواء جدة

Itselectricblender said...

The Electric Blender for people to save time and reduce stress The Comparisons vs Reviews Deal of best food processor, Best Smoothie Blender, Best Personal Blender, Best Commercial Blender, best portable blender, Best immersion blender, Best Vitamix Blender, best ninja blender,Best Magic Bullet Blender, best Blendtec blender, The comparisons between Blendtec vs Vitamix, of Magic Bullet vs NutriBullet is another issue to consider if you are looking for a smart and efficient blender. But the Nutri Ninja vs NutriBullet will help you to decide to get the right one. and Best Food Dehydrator, Best Food Chopper, best vegetable chopper Reviews, buying a guide.

Most Expensive Watch said...

If you want to know Most Expensive Watch. you can visit listforever.com here you will get Top 21 Most Expensive Watch | Pictures, Price and Specifications

Best Kukri said...

The 5 Best Kukri Machetes Reviews and Guide 2018 Have you been looking for the best kukri knife in the market Don t worry you are at the right place Visit this site to see reviews and choosing best one

Pet Medicine said...

Pet Pharmacy Petmeds and Pet Medicine Store Petsability is the Best Online Pet Pharmacy that provides Petmeds Pet Medicine Find Natural Medicines

Fastest Train said...

Top 12 Fastest Trains in the World Here are the world’s fastest trains in commercial service, ranked by their operating speed Top 12 Fastest Trains in the World

Hofstad Rijopleiding said...

Rijschool den haag Hofstad rijopleiding is écht gevestigd in Den Haag Wij helpen je met het behalen van je autorijbewijs na je rijexamen leer je pas echt autorijden Wij helpen je een heel eind op weg om het verkeer in Den Haag én in Nederland de baas te zijn Wij gaan voor kwalitatief rijden!

Utility kilt said...

Utility kilt is comfortable and easy to wear.you can read this post. it is a good informative post on yours.

Best Hand Blender said...

Need a helping hand with making dinner We have rounded up the Best Hand Blender to consider when adding to your kitchen gadgets

Rijschool Den Haag said...

Rijschool den haag Hofstad rijopleiding is écht gevestigd in Den Haag Wij helpen je met het behalen van je autorijbewijs na je rijexamen leer je pas echt autorijden Wij helpen je een heel eind op weg om het verkeer in Den Haag én in Nederland de baas te zijn Wij gaan voor kwalitatief rijden!

Transport company in Dammam said...

تقدم شركة شركة النقل في الدمام جميع عملائها مجموعة واسعة من الخدمات لم يتم رؤيتها قبل أي شركة أخرى لنقل الرغيف. كما سيقدم لك مجموعة كبيرة من الخصومات الضخمة على عمليات النقل التي تصل إلى 40٪.

Turbo Steam said...

Turbo Steam is a powerful, yet portable, fabric and clothes steamer for all of your steaming needs. Our Turbo Steam takes only 45 seconds to heat up and to start generating steam and its steam delivery system evenly distributes steam across fabrics to remove even the worst wrinkles.