Currently, I am looking to run a PowerShell script using Power Automate Desktop that will run through a service account. The service account is used so that if I or another member of tech leaves, the flows will live on.
I am currently in the beginning stage of creating a flow that will executive a pretty complex script but the first part is connecting to specific modules without having to use MFA. The account currently does not use MFA as it is not part of out OKTA and only has an Azure/Exchange account with a password that never expires.
The beginning of the script doesn't seem to connect to the required modules and goes as follows:
******************
#Arguments for connectivity
$User = "ServiceAccountAddressThatEndsWith.onmicrosoft.com"
$JPasswd = ConvertTo-SecureString -String "PASSWORD" -AsPlainText -Force
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $JPasswd
#connect to AzureAD service
write-host "Connecting to Exchange module"
Connect-ExchangeOnline -Credential $credential -ShowBanner:$false
*********************
I have added a simple GetMailboxPermissions command to the end of this and tried to run and it does not return any Outputs. When I run this on my personal desktop, I am able to connect to the Module and it does return the get mailbox permissions command properly. The issue seems to be when being ran with PAD.
Any guidance on this would be appreciated!