Powershell script "completed" but not doing anything

%3CLINGO-SUB%20id%3D%22lingo-sub-1254975%22%20slang%3D%22en-US%22%3EPowershell%20script%20%22completed%22%20but%20not%20doing%20anything%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1254975%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20run%20Powershell%20scripts%20from%20Flow%2C%20using%20this%20guide%3A%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fpractical365.com%2Fmicrosoft-365%2Fhow-to-run-powershell-scripts-to-automate-manual-processes-in-office-365%25C2%25A0%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fpractical365.com%2Fmicrosoft-365%2Fhow-to-run-powershell-scripts-to-automate-manual-processes-in...%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDuring%20testing%2C%20I%20run%20the%20runbook%20from%20the%20automation%20account%20(that%20is%2C%20I%20do%20not%20run%20the%20Flow%2C%20but%20just%20the%20Powershell%20commands)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20run%20into%20some%20issues%3A%3C%2FP%3E%3CUL%3E%3CLI%3EThe%20runbook%20is%20%22completed%22%20but%20the%20actions%20are%20not%20performed%20-%20nothing%20simply%20happens.%3C%2FLI%3E%3CLI%3EThe%20runbook%20is%20completed%20no%20matter%20what%20credentials%20I%20enter%2C%20and%20even%20if%20I%20delete%20the%20credentials%20completely%2C%20and%20even%20if%20I%20use%20a%20fake%20user%20ID%20for%20the%20Employee%20parameter.%26nbsp%3B%3C%2FLI%3E%3C%2FUL%3E%3CP%3EThe%20Powershell%20commands%20I%20want%20to%20run%20are%20these%20(with%20the%20actual%20e-mail%20addresses%2C%20of%20course)).%20Are%20there%20errors%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-javascript%22%3E%3CCODE%3EParam%20(%0A%5Bstring%5D%20%24Employee%20%3D%20%22%22%0A)%0A%24credObject%20%3D%20Get-AutomationPSCredential%20-Name%20%22ScriptServiceAccount%22%0AConnect-AzureAD%20-Credential%20%24credObject%0A%24User%20%3D%20Get-AzureADUser%20-ObjectId%20%24Employee%0ASet-AzureADUser%20-ObjectId%0AAdd-MailboxPermission%20%3CSHARED%20mailbox%3D%22%22%20e-mail%3D%22%22%20address%3D%22%22%3E%20-User%20%24Employee%20-AccessRights%20FullAccess%20-InheritanceType%20all%3C%2FSHARED%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3Band%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EParam%20(%0A%5Bstring%5D%20%24Employee%20%3D%20%22%22%0A)%0A%24credObject%20%3D%20Get-AutomationPSCredential%20-Name%20%22ScriptServiceAccount%22%0AConnect-AzureAD%20-Credential%20%24credObject%0A%24User%20%3D%20Get-AzureADUser%20-ObjectId%20%24Employee%0ASet-AzureADUser%20-ObjectId%0AAdd-UnifiedGroupLinks%20-Identity%20%3CO365%20group%3D%22%22%20e-mail%3D%22%22%20address%3D%22%22%20or%3D%22%22%20id%3D%22%22%3E%20-LinkType%20Members%20-Links%20%24Employee%0AAdd-UnifiedGroupLinks%20-Identity%20%3CO365%20group%3D%22%22%20e-mail%3D%22%22%20address%3D%22%22%20or%3D%22%22%20id%3D%22%22%3E%20-LinkType%20Owners%20-Links%20%24Employee%3C%2FO365%3E%3C%2FO365%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20runbook%20is%20completed%2C%20but%20the%20employee%20is%20not%20added%20as%20a%20member%2Fowner%20of%20the%20group%20and%20does%20not%20get%20access%20to%20the%20shared%20mailbox.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22dfgdsfgdsf.png%22%20style%3D%22width%3A%20998px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F179630i398B44D5D35AF03E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22dfgdsfgdsf.png%22%20alt%3D%22dfgdsfgdsf.png%22%20%2F%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Namnl%C3%B6s.png%22%20style%3D%22width%3A%20998px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F179631i290B132F988E4ADB%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Namnl%C3%B6s.png%22%20alt%3D%22Namnl%C3%B6s.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1254975%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAutomation%20%26amp%3B%20Control%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1275563%22%20slang%3D%22en-US%22%3ERe%3A%20Powershell%20script%20%22completed%22%20but%20not%20doing%20anything%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1275563%22%20slang%3D%22en-US%22%3E%3CP%3ENo%20one%20got%20an%20idea%3F%26nbsp%3B%3C%2FP%3E%3CP%3EI%20could%20really%20need%20some%20help.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

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.

 

dfgdsfgdsf.pngNamnlös.png

1 Reply
Highlighted

No one got an idea? 

I could really need some help.