How can I reference UWP classes in PowerShell
Shortly after posting this question, I stumbled on the GitHub repo for BurntToast, a module that allows raising UWP Toast Notifications from PowerShell, and it references the WinRT ToastNotificationManager type like this:
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime]
So, it looks like the syntax I'm after for UWP classes is:
[<class name>,<namespace>,ContentType = WindowsRuntime]
With this in mind, I tried it with the example I gave in the question and lo and behold:
PS C:\> $jsonObjectClass = [Windows.Data.Json.JsonObject,Windows.Data.Json,ContentType=WindowsRuntime]PS C:\> $jsonObject = $jsonObjectClass::Parse('{"data":["powershell","rocks"]}')PS C:\> $jsonObjectKey Value --- ----- data ["powershell","rocks"]
After referencing the type name once, I seem to be able to use the class name in a type literal without qualifying it as well:
[Windows.Data.Json.JsonObject]::Parse("{}") # works without throwing errors now
Still very keen to find any documentation on this though