Question

Freshservice Workflow: Powewrshell - Exchange OnPrem execution

  • 11 August 2022
  • 2 replies
  • 249 views

Userlevel 1
Badge +2

Hi everyone

Here comes a big one :-) I try to automate some Exchange tasks via the Powershell Orchestrator application. I have tried several ways all of them work, when I execute them directly on the server or from the server where the Orchestration application is installed. They just never work running it with in the Workflow. To take one thing out of the way, the user has admin rights on all server and Exchange execution rights.

I post the script and then below the error.

Situation 1
Configuration: Exchange server

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn
sleep 5
Set-MailboxAutoReplyConfiguration -Identity firstname.lastname@domain.com -AutoReplyState Enabled -InternalMessage "test" -ExternalMessage "test"

Result:

Active Directory operation failed on . The supplied credential for 'domain\service-account' is invalid. At line:3 char:1 + Set-MailboxAutoReplyConfiguration -Identity firstname.lastname@domain.com -Au ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], ADInvalidCredentialException + FullyQualifiedErrorId : [Server=Exchange,RequestId=43695f51-e920-4105-bb3f-99a3b871789b,TimeStamp=8/11/2022 12:04:30 PM] [FailureCategory=Cmdlet-ADInvalidCredentialException] 52ECAA27

Situation 2
Configuration: Exchange server

$session = New-PSSession -connectionURI "http://exchangeServer/powershell" -ConfigurationName Microsoft.Exchange
Import-PSSession -session $session

Set-MailboxAutoReplyConfiguration -Identity firstname.lastname@domain.com -AutoReplyState Enabled -InternalMessage "test" -ExternalMessage "test"

Result:

Connecting to remote server Exchange server failed with the following error message : A specified logon session does not exist. It may already have been terminated. For more information, see the about_Remote_Troubleshooting Help topic. At line:1 char:16 + ... $session = New-PSSession -connectionURI "http://exchangeServer ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException + FullyQualifiedErrorId : 1312,PSSessionOpenFailed Cannot validate argument on parameter 'Session'. The argument is null. Provide a valid value for the argument, and then try running the command again. At line:2 char:31 + Import-PSSession -session $session + ~~~~~~~~ + CategoryInfo : InvalidData: (:) [Import-PSSession], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.ImportPSSessionCommand The term 'Set-MailboxAutoReplyConfiguration' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:4 char:1 + Set-MailboxAutoReplyConfiguration -Identity firstname.lastname@domain.com -Au ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Set-MailboxAutoReplyConfiguration:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

Situation 3
Configuration: Active Directory server

Same result as in situation 2.

I running on the server via Powershell it works fine.

Any ideas?

Thank you all!


2 replies

Userlevel 7
Badge +16

Hello @alephtaph, I am not sure if this is the cause or not but a number of us have raised concerns that we don’t have a way to pass authorized credential information along with the Powershell Commands to execute, so if you have any restrictions on who is authorized to execute those commands (especially around the orchestration server agent) that could be why the first command is failing. I am no powershell expert by any means but that is just an area where we have had some trouble, especially in regards to PS commands with Active Directory. 

Take care!

Userlevel 1
Badge +2

Thank you @zachary.king, I was thinking the same. But I am able to execute almost everything in the ActiveDirectory. I even run the commands on the AD with the service account just to be sure that the user has the needed rights.

Reply