Mar 26 2020 03:18 AM
Hi,
I am trying to run Powershell scripts from Flow, using this guide: https://practical365.com/microsoft-365/how-to-run-powershell-scripts-to-automate-manual-processes-in...
During testing, I run the runbook from the automation account (that is, I do not run the Flow, but just the Powershell commands)
I have run into some issues:
The Powershell commands I want to run are these (with the actual e-mail addresses, of course)). Are there errors?
Param (
[string] $Employee = ""
)
$credObject = Get-AutomationPSCredential -Name "ScriptServiceAccount"
Connect-AzureAD -Credential $credObject
$User = Get-AzureADUser -ObjectId $Employee
Set-AzureADUser -ObjectId
Add-MailboxPermission <shared mailbox e-mail address> -User $Employee -AccessRights FullAccess -InheritanceType all
and
Param (
[string] $Employee = ""
)
$credObject = Get-AutomationPSCredential -Name "ScriptServiceAccount"
Connect-AzureAD -Credential $credObject
$User = Get-AzureADUser -ObjectId $Employee
Set-AzureADUser -ObjectId
Add-UnifiedGroupLinks -Identity <O365 group e-mail address or id> -LinkType Members -Links $Employee
Add-UnifiedGroupLinks -Identity <O365 group e-mail address or id> -LinkType Owners -Links $Employee
The runbook is completed, but the employee is not added as a member/owner of the group and does not get access to the shared mailbox.
Apr 02 2020 07:56 AM
No one got an idea?
I could really need some help.
Mar 04 2022 08:54 AM
I was having same issue because I created the runbook as Powershell type but using a workflow block, so it just ignores the code. Creating the runbook again with type Powershell Workflow worked.
Mar 06 2022 11:53 PM
@kengp Oh, nice, thanks! I haven't given this any more thought since öast post, but now I think I'll give it another try!
Mar 07 2022 06:02 AM
@Mårten Markne Glad to help. I used this tutorial and was successful setting up my automation: https://docs.microsoft.com/en-us/azure/automation/learn/automation-tutorial-runbook-textual
It is now recommended to use user assigned identities for logging in to Azure, rather than credentials.