Powershell Encoded Command (Base64) not working

I’m trying to use Invoke Power Shell activity to run a base64 encoded command. When I run in PowerShell it works, but the same command in UiPath appears to do nothing.

image
(The “IsScript” property is ticked on this activity)

The command is to send an email using a variation of:
“Send-MailMessage –From ‘Test User noreply@organisation.org.uk’ –To ‘user@example.com’ –Subject ‘subject’ -Body ‘body’ -SmtpServer smtp.mysmtpserver.org.uk -BodyAsHtml”

This is encoded from unicode to base64 using https://www.base64encode.org/

Can anyone advise how I can run a base64 encoded powershell through UiPath? Thanks

Hi @andrewjames, is there any error being thrown

1 Like

Not from UiPath… no.
image
If I run the same command, not encoded, it works fine.

Hi @andrewjames, why there is a need of encoding there
Just write the script directly and run it using the invoke powershell activity

Since it is an action of sending mail, kindly check whether mail is sent

1 Like

Encoding is needed due to complex quotations in the body of the email message. Powershell needs encoding to handle these.

However, I’ve found the solution… I’d missed a character off when cutting and pasting the base64 encoded text! Rookie error, but it does work now.

Thank you for your help

1 Like