This project is read-only.

is the powershell snapin needed?

Jul 10, 2012 at 8:40 PM

when using the execute powershell action, do all the scripts need the powershell snapin added?

if(-not(Get-PSSnapin | where { $_.Name -eq "Microsoft.SharePoint.PowerShell"}))
      Add-PSSnapin Microsoft.SharePoint.PowerShell;

i start all my scripts with the above code, but is it needed?

if(-not(Get-PSSnapin | where { $_.Name -eq "Microsoft.SharePoint.PowerShell"}))
      Add-PSSnapin Microsoft.SharePoint.PowerShell;
Jul 11, 2012 at 8:12 AM

No it isn't needed. It even doesn't work.

Jul 11, 2012 at 2:44 PM

i've used the above code in all my scripts and it works.

Just trying to eliminate overhead in the code.

Thank you for the reply!

Jul 16, 2012 at 6:49 PM

I am tryin to use this activity and it is giving me problems. It sounds like you are able to get code to execute when you use it. Care to share  some tips and help me out.
What I am tryiny to accomplish:

1. User fills out form with information to create new site collection
2. Create Site collection activity(3rd party) triggerd by form submitted creates site collection (This works for me)
3. iLSP Powershell activity with script to move Site collection to desired content database; based on criteria in the form. (want to map site collections to content databases based on managed paths; i.e. http://<root>/<managed_path>/<site_name> is placed in content database "WSS_Content_<managed_path>)

I cannot get code to execute using this wf activity.

Can you shed some light on this?

Jul 18, 2012 at 9:09 AM

Could you provide any further details like error message and stacks strace from the SharePoint log file. 

Keep in mind that the PowerActivity runs under the permssion of the application of the current web site. Usually this app pool has not the permission to do such an operation. I would recommend to create an external service that has farm admin permissions and call the service from workflow. Another pattern could be to save which site to move in a property bag or a list. create a powershell that performs the move operation via the windows scheduler.

Bye, Christian 

Jul 23, 2012 at 6:50 PM

if i don't load the snapin, this is the error i receive:

Error while executing PowerShell Script: The term 'Get-SPweb' 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.

it's not a big deal, just wanted to ask...