Reputation: 33
Please forgive the cross posting between reddit.com/r/PowerShell and here.
Up until a few days ago the behavior of using [type]
and a particular typename was consistent between powershell.exe, pwsh.exe, and powershell_ise.exe. Now it is different and I haven't made any user initiated changes.
I've tried specifying -noprofile
at the command line and the same erroneous behavior. Below is some sample command output between the different incarnations of PowerShell.
(PSv5) C:\Users> [System.Windows.WindowState]
Unable to find type [System.Windows.WindowState].
At line:1 char:1
+ [System.Windows.WindowState]
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Windows.WindowState:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
(PSv7) C:\Users> [System.Windows.WindowState]
InvalidOperation: Unable to find type [System.Windows.WindowState].
(PS_ISEv5) C:\Users> [System.Windows.WindowState]
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True WindowState System.Enum
Note how (PS_ISEv5) is the only one providing the expected result.
I'm at a loss as to where to dig deeper to find root cause. My Google-Fu is not providing any insight. Anyone have any breadcrumbs to point me in the right direction?
I tried loading powershell.exe and pwsh.exe with -noprofile and the behavior was the same. I've attempted to search on Google and nothing useful was returned.
Upvotes: 2
Views: 168
Reputation: 18051
You could load the PresentationFramework
assembly yourself:
[Reflection.Assembly]::LoadWithPartialName("PresentationFramework")
or
Add-Type -AssemblyName "PresentationFramework"
It makes sense that this WPF assembly is already loaded in the PowerShell ISE GUI application.
Upvotes: 3