Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Create Site Collection - Workflow and powershell interaction

$
0
0

I have a question,

as per Infrastructure team needs, they want to have the own of the sitecollection script creation to maintain and change it.
Now, we need, in some way, to call that script and receive a message of the status of the site collection creation.

We had a page on Sharepoint in which users, after filled a simple form, 
can send a request for a site collection creation.
When they click on Send button, we create an item on a list and our Workflow starts,
asking for approval of site creation, if the approval user approves the request,
the workflow calls a webservice hosted on sharepoint, this webservice
will call the powershell process and the powershell script will create the site collection.

Even if the powershell is not of our due, I would be sure that it works,
My two problems are:
1) I'm able to call the powershell from the service but I don't know why the powershell ony whe lauche from the service can't add the sharepoint psnapin, for example the script is:

Add-PSSnapin "Microsoft.SharePoint.PowerShell"

$template = Get-SPWebTemplate "COMMUNITY#0"

New-SPSite -Url "http://mywebapp/sites/NewCommunitySite" -OwnerAlias "domain\username" -Template $template

the error is:

Add-PSSnapin : The Windows PowerShell snap-in 'Microsoft.SharePoint.PowerShell' is not installed on this computer.At C:\temp\createSiteCollection.ps1:1 char:1+ Add-PSSnapin Microsoft.SharePoint.PowerShell+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    + CategoryInfo          : InvalidArgument: (Microsoft.SharePoint.PowerShel    l:String) [Add-PSSnapin], PSArgumentException    + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.Ad    dPSSnapinCommand


websservice and powershell run on the Sharepoint Server.

2) how could i have a response of the successful or failed creation from the powershell to the service?

I can check the standard out messagges but I don't if it is a good idea. Below a piece of my webservice code.

myProcess = new Process();
startInfo = new ProcessStartInfo("C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\Powershell.exe");
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;                
startInfo.Arguments = @"""C:\temp\createSiteCollection.ps1"" 'agrs'";
                myProcess = Process.Start(startInfo);
stdoutx = myProcess.StandardOutput.ReadToEnd();
....
.....




I will appreciate your help!

Thanks and regards.


Maxx


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>