Task from the Task Scheduler doesn’t load localized string

Welcome Forums General PowerShell Q&A Task from the Task Scheduler doesn’t load localized string

Viewing 2 reply threads
  • Author
    Posts
    • #273319
      Participant
      Topics: 1
      Replies: 1
      Points: 13
      Rank: Member

      First of all files’ simplified structure.

      root\en-US\test.psd1

      root\test.ps1

      root\test.psd1

      So the problem is that despite the string CleanUpTaskToast was loaded from the localization file, the variable is not interpreted as a string but as $($Localization.CleanUpTaskToast) whatever I do. It does work but not within running from the Task Scheduler. I know the more rational method is to try to run script for task from a file, but I do want to create totally independent task. I know there are some errors appear after task running but it’s not the problem (it can be solved with tripple double-quotes). It is just the origin version of code.
      So can anyone make the script to load localized string while creating this task?

       

       

      • This topic was modified 1 month, 4 weeks ago by farag59.
    • #273388
      Participant
      Topics: 17
      Replies: 1951
      Points: 3,988
      Helping Hand
      Rank: Community Hero

      Rather than using a global variable, it should be passed to the function. Why create a function to get a scriptBlock rather than just defining a variable as a a scriptblock? Would also recommend using more descriptive variables. When reading the code there is $test and task is test and a function named xml with [xml]. It just makes it difficult to read and troubleshoot, just .02. Here is something you can try:

    • #273472
      Participant
      Topics: 1
      Replies: 1
      Points: 13
      Rank: Member

      I do not think this is a solution. I use

      Also actually i presented this function as simplified example. The main project ishttps://github.com/farag2/Windows-10-Sophia-Script . As you can see I use preset file to users edit it by themselves. So I have no idea how to make script to interpret this variable as a localized string.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.