Paul π
Paul π

Reputation: 519

How to reference localized strings in a module's ScriptsToProcess script?

Consider the scenario:




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)?

Upvotes: 0

Views: 14

Answers (1)

Paul π
Paul π

Reputation: 519

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.

Upvotes: 0

Related Questions