Start a new topic
Solved

Receiving error trying to use trying to use a dynamic folder script with powershell

When attempting to do what I mentioned in the subject I receive the following error, this is on Windows 11 24H2 fully patched. I also set the following settings and as of now they both sit at bypass.

An error occurred while executing the dynamic folder's script: "File C:\Users\troyc\AppData\Local\Temp\Royal TS V7\DynF_866d5504-5499-4a32-a01d-12766fe08b8d_1736232706.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. + CategoryInfo : SecurityError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : UnauthorizedAccess"  

image.png
(22.7 KB)

Hi Troy,


you may need to set the execution policy to Unrestricted in order to make it work. Also check the Options -> Dynamic Folder page to see if you are referring to the PowerShell 7 executable:

https://www.royalapps.com/go/help-ts-win-v7-ref-options-scriptinterpreter


The latest version of Royal TS now supports setting environment variables instead of using replacement tokens. Check this thread: https://support.royalapps.com/support/discussions/topics/17000024626


With environment variables you could sign your scripts you place in the dynamic folder/credential scripts.


Let me know if this helps.


Regards,
Stefan

I found out a way, for others sake I'll post it here. This is on Windows 11 Pro 24H2.

In addition to Set-ExecutionPolicy RemoteSigned

I did the following;

Create a GPO and go to Local Computer Policy > Windows Administrative Templates > Windows Components > Windows Powershell > Turn on Script Execution set to Enabled and set execution policy to allow Local and Remote Signed scripts.

Thanks for sharing your solution! Glad you got it working.


cheers,
Stefan

Oh and yes I was using the latest powershell 7.4.6, 

I also realize I should have posted this under problems. I'm not sure but if a moderator can mark this as solved and move to proper forum or have solution posted that would be great.

I moved the topic to the correct forum.

I encounter the same issue in our environment.


Can you pls explain your post a bit, especially how the script can be signed?:

The latest version of Royal TS now supports setting environment variables instead of using replacement tokens. Check this thread: https://support.royalapps.com/support/discussions/topics/17000024626


With environment variables you could sign your scripts you place in the dynamic folder/credential scripts.

To read more about script signing, you can read the docs here:

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_signing?view=powershell-7.5


Regards,
Stefan

Hi Stefan,

signing the skript and using environment variables will not be the problem. I'm just confused where to put my skript? Maybe I am missing something but the skript seems to be created dynamically under Temp during execution.

You still need to put the script in the dynamic folder configuration - including the signature at the very bottom of the script. The script will then be created under temp but since it is the very same signed script including the signature, it will run on your system. 


Note: if the dynamic folder is not configured to use the environment variables under Advanced, it will try to replace the tokens and therefore the script will change and the signature will be invalid. So make sure you configured the dynamic folder to use environment variables.


Let me know if this helps.


Regards,
Stefan

Login or Signup to post a comment