Hi i'm making an onboarding flow which in Power Automate cloud which will create a user, assign them to a department and add them to a distribution list accodrding to their department and generate aliases based on their email adress.
In order to accomplish this I need to use a Powershell script running in an Azure Automation Runbook since Power Automate does not allow me to assign someone to a distribution list.
I have managed to successfully create a Power Automate flow which creates users, as well as a Powershell script that a user to a distribution list and creates the alias. However I don't know how to "tie these two together". I know i need to use the "Create Job" action for Azure Automate in Power Automate however I don't know how exactly I would get powershell to recognize variables generated by Power Automate.
I do agree with @swathidhanwada, I have reproduced from my end and see this is working fine when I pass UserPrincipleName
in JSON format.
Below is the flow in my logic app
Code view of the Create job
step
{
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['azureautomation_1']['connectionId']"
}
},
"method": "put",
"body": {
"properties": {
"parameters": {
"UPName": "@{body('Create_user')?['userPrincipalName']}"
}
}
},
"path": "/subscriptions/@{encodeURIComponent('<SUBSCRIPTIONID>')}/resourceGroups/@{encodeURIComponent('<RESOURCEGROUPNAME>')}/providers/Microsoft.Automation/automationAccounts/@{encodeURIComponent('<AUTOMATIONACCOUNTNAME>')}/jobs",
"queries": {
"x-ms-api-version": "2015-10-31",
"runbookName": "runbook",
"wait": false
}
}
}
Here is the script in my runbook
Param(
[string] $UPName
)
Write-Output “$UPName”
Add-DistributionGroupMember -Identity <IDENTITY> Member $UPName
Results: