Get translation scope variable with variable name?

Hey folks,

I have a few areas in a dashboard that are returning data that will always have one of a few possible values. I was thinking I could somehow include the value in a translation hashtable name to call its value but I don’t seem to be able to do so with a partially variable name. Get-Variable doesn’t have the custom T scope in its ValidateSet, Get-PSUVariable spit out a very long error message* and I couldn’t get Invoke-Expression to play nice either.

Any suggestions, or should I just write a custom function to handle these explicitly?

*error message:

Status(StatusCode="Unknown", Detail="Exception was thrown by handler.", DebugException="Grpc.Core.Internal.CoreErrorDetailException: {"created":"@1663772104.169000000","description":"Error received from peer ipv6:[::1]:65127","file":"..\..\..\src\core\lib\surface\call.cc","file_line":953,"grpc_message":"Exception was thrown by handler.","grpc_status":2}")
Product: PowerShell Universal
Version: 3.3.1

I just want to make sure I understand it. You want to dynamically load something from the translation scope?

This one worked for me.

  $MyKey = "String1"
  Show-UDToast (Invoke-Expression "`$T:$MyKey")

I actually just ran into a bug with this but in the next version, this will work as well.

  $MyKey = "String1"
  Show-UDToast (Get-Item "T:$MyKey")

The custom scopes aren’t actually scopes at all but PSProviders so they should work with the Get-Item cmdlets.

    $Cache:Nice = "Cool"
    Show-UDToast (Get-Item "Cache:Nice")

This is exactly what I was looking for, and thanks for the additional colour!