Check out the workflow action, Create AD user and see if it could work for your use case. It may do the same thing your powershell script is trying to do.
Jason
Thank you for your reply. It’s an interesting module. But it does not really offer all the functionality I am looking for.
Such as adding information to custom AD-User Attributes. Do you know a way how I can execute PowerShell Code from within my workflow like the Nintex RPA PowerShell module.
I don’t know of a Nintex supported way to call an external PowerShell script like that in Nintex for SP off the top of my head. I’ll ask around to see if anyone has implemented something in the past.
Hi @Nintex_Admin_xyz
there is an extension here but it is a couple years out of date and I cannot guarantee it will work:
Alternatively I would recommend looking into building an event receiver that looks at a given Sharepoint list, when an item is created in the list it can execute a Powershell script, that way Nintex would only need to populate the list with the users you want to create and the Powershell script will react to it, I would recommend having the Powershell script remove the records from the list on completion to ensure no unwanted build-up.
this is the article for visual studio:
https://learn.microsoft.com/en-us/visualstudio/sharepoint/how-to-create-an-event-receiver?view=vs-2022&tabs=csharp
TL:DR-
- Open Visual Studio.
- Create a new SharePoint 2019 - Empty Project.
- Right-click on the project in Solution Explorer > Add > New Item.
- Choose "Event Receiver" and name it.
- Choose the type of event you want (in your case, an item added event for a list).
It should generate an ItemAdded method in the receiver and you can add logic like this to execute a script:
System.Diagnostics.Process.Start("powershell.exe", @"& 'C:\path\to\your\script.ps1'");
Then to attach your event receiver to a specific list you need to edit the Elements.xml like below, the list ID template of 100 will be attached.:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Receivers ListTemplateId="100">
<Receiver>
<Name>MyEventReceiverItemAdded</Name>
<Type>ItemAdded</Type>
<Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
<Class>YourNamespace.YourEventReceiverClassName</Class>
<SequenceNumber>10000</SequenceNumber>
</Receiver>
</Receivers>
</Elements>
Another way which I prefer would be to use Powershell to attach it which can happen after you deploy it by right clicking on the project in VS and deploying.
Add-PSSnapin Microsoft.SharePoint.PowerShell
$web = Get-SPWeb "http://your_sharepoint_site_url"
$list = $web.Listsi"Your List Name"]
$eventReceiver = $list.EventReceivers.Add()
$eventReceiver.Assembly = "YourAssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=your_public_key_token"
$eventReceiver.Class = "YourNamespace.YourEventReceiverClassName"
$eventReceiver.Type = eMicrosoft.SharePoint.SPEventReceiverType]::ItemAdded
$eventReceiver.SequenceNumber = 1000
$eventReceiver.Update()
$web.Dispose()
If you don’t have VS then I think you can do this in VS code but I have never done it, most of what I am writing here is from memory/articles such as this which covers event receivers in more detail:
https://www.c-sharpcorner.com/article/introduction-of-sharepoint-event-receivers/
Jake