Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I would like to build an InfoPath form that users can use to request a new Active Directory account (e.g. for a new employee). Once the form is submitted, I would like it to then run a PowerShell script using the supplied values from the form as parameters to the script. The script will create a new Active Directory user using these values.

I can run a PowerShell script from a C# application by importing the System.Management.Automation assembly (example), and while I could add the users directly through C# with System.DirectoryServices, our requirement is to have several forms that collect different information which are passed to specific scripts that are managed by our IT department (the adding users script for example would perform some other tasks beyond simply creating the user and IT would like control over this). I understand that the PowerShell script would somehow have to be run as a user with rights to add users in the domain.

I have no experience with InfoPath. Can InfoPath call PowerShell scripts using the information that was submitted?

share|improve this question
1  
I know there are workflow tools that can do this, like Nintex. Outside of that, I'm not sure. I want to say it'd be out of the scope of functionality of InfoPath and that you'd need to do this with an event receiver (if it's even possible to execute PS via an event receiver). –  PirateEric Jun 8 '12 at 14:59
    
That's a good point, I didn't consider whether you could even call a PowerShell script from SharePoint... –  shufler Jun 8 '12 at 15:01
    
This question is unrelated to Sharepoint. Besides it is destructive, i.e. asking how to crack the information security systems –  Gennady Vanin Novosibirsk Jun 12 '12 at 2:55
    
I don't read it as a "destructive" question... shufler is trying to come up with a solution for managing new employees so the question seems a little strange. –  Kit Menke Jun 12 '12 at 3:07
    
It would have been if he have asked about managing employees but not about automatic executing by them the tasks of administration of Windows infrastructure from Infopath. How is it related to Sharepoint at all? –  Gennady Vanin Novosibirsk Jun 12 '12 at 3:58
add comment

3 Answers

up vote 3 down vote accepted

I would create a powershell script and have it run every few minutes. Powershell would basically look for newly created record in SharePoint Library or List (you can probably create column "Status" and set default value to "New" and change it to "Processed" after creating AD account with powershell).

Here is a good link on Powershell for SP 2010 http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/22/use-powershell-to-manage-lists-views-and-items-in-sharepoint.aspx

share|improve this answer
    
This is an interesting suggestion, as it introduces a workflow concept to the solution so it's clear whether the PS processing has run or not. This makes me think using a well known and supported 3rd party workflow tool may be better suited than building this myself. –  shufler Jun 8 '12 at 15:03
    
+1 this is a great option. A workflow or scheduled console application / powershell script is the way to go. It is fairly easy to parse infopath forms since they are just XML. To answer @shufler's question though.. no it is not possible to call a powershell script directly from an infopath form. –  Kit Menke Jun 12 '12 at 3:08
    
Kit Menke, thanks. Though, why is my reply directly answering NO to question is downvoted and the reply presenting the answer to what had not even been asked is being upvoted and marked as correct? I do not think it is good for community - for those who spend their time trying to correctly answer and those who search for correct answers since downvoted replies tend to be ignored –  Gennady Vanin Novosibirsk Aug 15 '12 at 13:01
add comment

I do not understand why you need to couple "InfoPath call PowerShell scripts using the information that was submitted?"

Collecting/extracting user information and its use are quite separate independent activities.

You may consult InfoPath Services cmdlets (SharePoint Server 2010) about Infopath PowerShell options.

And for collecting user information collection by and extraction from Infopath, look into "Sharepoint User Profile Web Service"

Then. answer to your question depends whether you are going to use client IP forms which have less authentication complexities than stateless browser forms, via XMLHTTP protocol (the browser form cannot pass through user credentials to remote data sources the same way regular Infopath forms can, via NTLM).

Update:
The simple answer to question:

  • "Can an InfoPath Form call a PowerShell script that makes use of the submitted form values?"

is : "NO"
and I would have been extremely surprised if it was possible.

It is not business requirements, it is requirement for security breach, business stupidity for those who order it and those who fulfill such "business requirements"

share|improve this answer
    
The InfoPath Forms services cmdlets are more or less for managing InfoPath Forms services. It does not appear to me that any of these can be used as a way of extracting data. –  shufler Jun 11 '12 at 17:24
    
(For the example of AD accounts) The business requirement is to have a user account automatically created after the form is submitted. The purpose of integrating an InfoPath form and PowerShell is that they accomplish two different tasks: on the front end, InfoPath provides a user-friendly collection (and documentation) system, and on the back end, a PowerShell script developed by the IT department automates the account creation. My question is how can I integrate the two components? –  shufler Jun 11 '12 at 17:27
    
lets keep the tone sober, shall we? (about deleted comments). –  Anders Rask Aug 15 '13 at 6:33
add comment

I too would like to understand if this is actually possible for different reasons.

Putting the AD example aside for now as it seems to agitate certain people; is it possible to create a submit button on the InfoPath form that when pressed activates c# code that takes the values entered into the form as variables. If so, does anyone have a code example that takes the value of, say, control item my_control and enters it into a variable my_variable? Lets say the xpath of the control item is /my:myFields/my:my_control.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.