PowerShell 7 class seems not supported

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 1 year and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Stephane_Schaumburg
Posts: 2
Last visit: Sun Mar 17, 2024 11:09 pm

PowerShell 7 class seems not supported

Post by Stephane_Schaumburg »

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build:PowerShell Studio 5.8.208
Operating system:Windows 10 ENTERPRISE
PowerShell version(s):7.2.5

using namespace System.Management.Automation

Class SupportedResolution: system.management.automation.IvalidateSetValuesGenerator
{
[string[]] GetValidValues()
{
$Monitors = get-ciminstance -N "root\wmi" -Class WmiMonitorListedSupportedSourceModes
$PossibleModes = new-object -TypeName system.collections.arraylist
foreach ($LoopInMonitors in $Monitors)
{
foreach ($LoopInPossibleResolution in $LoopInMonitors.MonitorSourceModes)
{
$CurrentResolution = "$($LoopInPossibleResolution.HorizontalActivePixels) X $($LoopInPossibleResolution.VerticalActivePixels)"
$PossibleModes.add($CurrentResolution) | out-null
} # END foreach ($LoopInPossibleResolution in $LoopInMonitors.MonitorSourceModes)
} # END foreach ($LoopInMonitors in $Monitors)
return $PossibleModes

}

} # END Class SupportedResolution : system.management.automation.IvalidateSetValuesGenerator

DO NOT POST LICENSES, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM

This works in PS 7.2.5 console, also in VScode but PowerShell studio still signal it as error
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: PowerShell 7 class seems not supported

Post by Alexander Riedel »

Can you please clarify what you mean with "still signal it as error"?
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
brittneyr
Site Admin
Posts: 1654
Last visit: Wed Mar 27, 2024 1:54 pm
Answers: 39
Been upvoted: 30 times

Re: PowerShell 7 class seems not supported

Post by brittneyr »

Please do not post duplicate questions in different forums.

The class System.Management.Automation.IvalidateSetValuesGenerator is only available in PowerShell 7. Please verify that you have PowerShell 7 selected in the ribbon:
SPS_RibbonPlatformVersion.png
SPS_RibbonPlatformVersion.png (30.02 KiB) Viewed 1828 times
If this is not the issue, can you please provide a screenshot of the application with the file open?
Brittney
SAPIEN Technologies, Inc.
Stephane_Schaumburg
Posts: 2
Last visit: Sun Mar 17, 2024 11:09 pm

Re: PowerShell 7 class seems not supported

Post by Stephane_Schaumburg »

Picture attached.
I am really in V7 as you'll see in the picture.
So the powershell version is not the issue.
Attachments
ErreurClass.png
ErreurClass.png (429.35 KiB) Viewed 1552 times
User avatar
brittneyr
Site Admin
Posts: 1654
Last visit: Wed Mar 27, 2024 1:54 pm
Answers: 39
Been upvoted: 30 times

Re: PowerShell 7 class seems not supported

Post by brittneyr »

Interesting. I have not been able to reproduce that behavior.

Does the script report an error if you attempt to run it?
Does the error go away if you format the script from the ribbon (Home->Edit):
SPS_FormatScript.png
SPS_FormatScript.png (16.37 KiB) Viewed 1499 times
Brittney
SAPIEN Technologies, Inc.
This topic is 1 year and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.