question

lrarbin avatar image
0 Votes"
lrarbin asked lrarbin edited

Text with apostrophe in Azure Automation Runbook - PowerShell 7.1

Hello,
I have a Runbook running under PowerShell 7.1 with a number of parameters. One parameter is a 'Description' string which is effectively 'free' text. The problem I'm having is that the Runbook fails immediately if the parameter contains an 'apostrophe' i.e. a '

I've tried using:
- an escape character /
- Switching it for [char]0x002 (unicode)

I'm wondering if this is a bug?
Thanks
Laurence



azure-automation
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @lrarbin,

I have tried to reproduce the issue in my lab environment and I could see issue with Get-AzAutomationVariable or New-AzAutomationVariable cmdlet in both runtimes 5 .1 and 7.1 preview that too with or without apostrophe in the variable value. But it works with out any issue if you use Get-AutomationVariable -Name "xxxxx" so I would recommend you to try it and let me know if it helps.

On the other hand, I am reaching out to our internal product team to confirm about the Get-AzAutomationVariable or New-AzAutomationVariable cmdlet issue and will keep you updated as I hear more information.

1 Vote 1 ·

1 Answer

lrarbin avatar image
0 Votes"
lrarbin answered lrarbin edited

Hello @tbgangav-MSFT,
Thanks. I've managed to work around the issue by replacing ' with '', as I was using the wrong escape character.

This does make the Power Automate Flow variable for the Runbook data a little confusing:

 replace(triggerOutputs()?['body/txtPurpose'],'''','''''')

Thanks for the help.
Laurence



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.