0

Consider the scenario:

  • A module manifest's ScriptsToProcess key refers to an intitialization script -- which is designed to throw an exception if pre-requisites aren't satisfied (providing an additional layer of checks beyond what the manifest schema offers), thus preventing the module from loading
  • The module implements localized strings, stored in ModuleFolder\<langId>\ModuleResources.psd1
    • The .psm1 script imports the localized string messages by running the Import-LocalizedData cmdlet right after the data section
    • Additionally, the author's choice of default language localization strings are also stored in a data section in the beginning of the .psm1 module script in the event that the <langId> folders are missing/deleted



In the event that the init script throws an exception, how do you reference those localized string messages in the init script (as the .psm1 script fails to even load)?

1 Answer 1

0

I figured this out and feel like a moron.

The solution is to use the Import-LocalizedData cmdlet in the init script (in this case, inside of a catch{} block, before an exception is thrown) so that any exception message arguments can use your localized error message strings.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.