Hello and welcome to our forums,
Most likely, your PowerShell script refers some items that can not be found when you test it. The "test" functionality is not really for scripts like yours, that install something.
However, this should work when the custom action is executed (when the setup is run).
Please note, however, that you have not added your file as a
temporary file.
Unlike Advanced Installer's regular files or resources, "Temporary Files" are copied on the target machine at the beginning of the installation and are deleted at the end of it, ensuring you have access to them throughout the entire install process.
As you can see in the article I've linked above, temporary files have a specific icon.
Now this depends on when you want to execute the PowerShell script. For instance, if you want to execute it towards the end of the installation, there's no need to add your script as a temporary file.
One thing to be kept in mind here is the fact that two installation processes can not be run at the same time on the same computer. This is a limitation of the Windows OS.
Hope this helps!
Best regards,
Catalin