Forum Discussion
MrMrkn
Mar 26, 2020Copper Contributor
Powershell script "completed" but not doing anything
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 runbook is "completed" but the actions are not performed - nothing simply happens.
- The runbook is completed no matter what credentials I enter, and even if I delete the credentials completely, and even if I use a fake user ID for the Employee parameter.
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.