I tend to do most of my automation using AutoHotkey, for example to automate tweaks to new installs of Windows. Windows 10 has made things more difficult (deliberate obfuscation, in my opinion) so there are times when only PowerShell can be used, for example to automate the uninstallation of Windows 10s built-in apps.
Whilst I was testing an AutoHotkey script that tweaks a new install of Windows 10 I discovered a gotcha which had me beaten for a while. The following will demonstrate what I ran into.
Screenshot of AHK script calling PowerShell with successful result:
44938-ps_gotcha1
Click to enlarge
Screenshot of amended AHK script showing reproducible error about a missing curly brace. (It’s not missing!)
44939-ps_gotcha2
Click to enlarge
The only difference is that I added a comment to the end of the PowerShell section.
Note that error cannot be reproduced in the PowerShell ISE or just running a PowerShell (.PS1) script instead.
Hope this helps if anyone else uses AutoHotkey with Powershell…