SharePoint Server 2013

Hi,

How to call powershell script file from EventReceiver.

When item is added ,it will call power shell script from Event Receiver.I  have tried with this below code but i cant find good result

 public override void ItemAdding(SPItemEventProperties properties)
        {
            Process myProcess = new Process();
            myProcess.StartInfo.UseShellExecute = true;
            myProcess.StartInfo.FileName = @"F:\profileupdate.ps1";
            myProcess.StartInfo.CreateNoWindow = true;
            myProcess.Start();
        }

August 18th, 2015 2:35am

Hi,

I tried with your code in my environment, it turns out that the PowerShell Script is not being able to be executed when running it in an Event Receiver as a farm solution, though it did work in a Console Application project.

As a workaround, I would suggest you implement the similar functionality using C# in the Event Receiver instead.

Thanks
Free Windows Admin Tool Kit Click here and download it now
August 20th, 2015 11:18am

Hi,

Can u plz give simple workaround for that

August 30th, 2015 11:27pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics