# Replacing tokens in dynamic folders with Powershell

**URL:** https://community.royalapps.com/t/replacing-tokens-in-dynamic-folders-with-powershell/1904
**Category:** Royal TS (for Windows)
**Created:** [February 8, 2024, 8:54pm UTC](https://community.royalapps.com/t/replacing-tokens-in-dynamic-folders-with-powershell/1904 "2024-02-08T20:54:24Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![damien](https://community.royalapps.com/letter_avatar_proxy/v4/letter/d/9de053/32.png) [@damien](https://community.royalapps.com/u/damien)
#### Post date: [February 8, 2024, 8:54pm UTC](https://community.royalapps.com/t/replacing-tokens-in-dynamic-folders-with-powershell/1904/1 "2024-02-08T20:54:24Z")

</div>

In Dynamic Folders with Powershell, the script is transformed to replace RoyalTS variables of the type $xxxx$ (example: $EffectiveUsername$).

In my code, if I put one of these lines :

$MyFilePath = Get-Content -Path “${RootPath}${Environment}\_server\_list.csv”

$MyFilePath = Get-Content -Path “${RootPath}$($Item.Environment)\_server\_list.csv”

I get the warning “At least one token couldn’t be resolved” in the RoyalTS logs.

The 2 lines of code are valid and working Powershell code.

I have the impression that you’re replacing variables with a regexpr of the form $\w$, i.e. all characters except space character work. In fact, the following line doesn’t generate the warning:

$MyFilePath = Get-Content -Path “${RootPath} ${Environment}\_server\_list.csv”

due to the space.

Among all the variables provided by RoyalTS, only the following characters seem to be used: a-z A-Z 0-9 . - :

Is it possible to update the variable replacement mechanism so that it doesn’t try to replace if there is one of these characters: ( ) { } between the 2 $ ? To have the same behavior as if it were a space character?

Thanks

---

<div class="post-metadata">

### Author: ![stefan\_koell](https://community.royalapps.com/user_avatar/community.royalapps.com/stefan_koell/32/9_2.png) [@stefan\_koell](https://community.royalapps.com/u/stefan_koell)
#### Post date: [February 12, 2024, 8:44am UTC](https://community.royalapps.com/t/replacing-tokens-in-dynamic-folders-with-powershell/1904/2 "2024-02-12T08:44:30Z")

</div>

Hi Damien,

We are aware of some script languages which may interfere with our token resolution logic and we do have plans to address this at some point. In the meantime you can safely ignore these warnings.

Regards,  
Stefan

---

<div class="post-metadata">

### Author: ![stefan\_koell](https://community.royalapps.com/user_avatar/community.royalapps.com/stefan_koell/32/9_2.png) [@stefan\_koell](https://community.royalapps.com/u/stefan_koell)
#### Post date: [October 3, 2024, 1:15pm UTC](https://community.royalapps.com/t/replacing-tokens-in-dynamic-folders-with-powershell/1904/3 "2024-10-03T13:15:19Z")

</div>

Hi!

7.3 beta is available here:

[https://www.royalapps.com/go/kb-ts-win-downloadbeta](https://www.royalapps.com/go/kb-ts-win-downloadbeta)

On the **Advanced** page in your Dynamic Folder configuration you can now use environment variables as an alternative in your dynamic folder and credential scripts.

Would be great if you can test that feature and provide feedback.

---

<div class="post-metadata">

### Author: ![damien](https://community.royalapps.com/letter_avatar_proxy/v4/letter/d/9de053/32.png) [@damien](https://community.royalapps.com/u/damien)
#### Post date: [October 28, 2024, 12:53pm UTC](https://community.royalapps.com/t/replacing-tokens-in-dynamic-folders-with-powershell/1904/4 "2024-10-28T12:53:20Z")

</div>

This idea is repeated here [Evolution proposals for dynamic folder with PowerShell](https://community.royalapps.com/t/evolution-proposals-for-dynamic-folder-with-powershell/1998)  
I tested the latest beta version and everything seems fine.

---

<div class="post-metadata">

### Author: ![stefan\_koell](https://community.royalapps.com/user_avatar/community.royalapps.com/stefan_koell/32/9_2.png) [@stefan\_koell](https://community.royalapps.com/u/stefan_koell)
#### Post date: [October 28, 2024, 1:04pm UTC](https://community.royalapps.com/t/replacing-tokens-in-dynamic-folders-with-powershell/1904/5 "2024-10-28T13:04:00Z")

</div>

Thanks for the feedback, Damien!
