profile issue

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 6 years and 11 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.
User avatar
teejay58
Posts: 10
Last visit: Mon Jan 08, 2024 8:30 am

profile issue

Post by teejay58 »

Product, version and build: Powershell Studio 4.1.75
(*** Please do not write "latest" as a version, specify a version number ***)
32 or 64 bit version of product: 64
Operating system: Windows 7
32 or 64 bit OS: 64
PowerShell Version: 4,0

I have the following lines of code in my profile.ps1 script in C:\Windows\System32\WindowsPowerShell\v1.0:

$Host.PrivateData.DebugBackgroundColor = "Black"
$Host.PrivateData.DebugForegroundColor = "Yellow"

$Host.PrivateData.ErrorBackgroundColor = "Black"
$Host.PrivateData.ErrorForegroundColor = "Orange"

When I run the regular posh IDE, it works just fine. But when the profile runs in Studio, I get an error message regarding the color, Orange:

Exception setting "ErrorForegroundColor": "Cannot convert value "Orange" to
type "System.ConsoleColor". Error: "Unable to match the identifier name Orange
to a valid enumerator name. Specify one of the following enumerator names and
try again: Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta,
DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White""
At C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1:19 char:1
+ $Host.PrivateData.ErrorForegroundColor = "Orange"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], SetValueInvocationExceptio
n
+ FullyQualifiedErrorId : ExceptionWhenSetting

What's going on? Is the profile in Studio running after powershell is already loaded? And maybe the one in the microsoft IDE runs before it loads powershell?
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: profile issue

Post by davidc »

You are running host dependent code. Meaning that the ISE host has these properties, but the PowerShell Studio host does not. Chances are any host outside of ISE will not have these properties.
David
SAPIEN Technologies, Inc.
User avatar
teejay58
Posts: 10
Last visit: Mon Jan 08, 2024 8:30 am

Re: profile issue

Post by teejay58 »

I'm confused, David. In another forum post, you assured the poster that Studio was running the same powershell code as he used with the M$ IDE. Are you guys modifying the code that outputs to the console for powershell? Also, why do my other colors work right? Orange is the only one that balks.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: profile issue

Post by davidc »

The host is different than the PowerShell engine. The host is the intermediary layer between the user and the PowerShell engine. The PowerShell ISE is its own host and the console is another host. Therefore, context makes the difference.

Are you referring to the embedded console or PowerShell Studio's internal host? Because PowerShell Studio's internal host does not use a console to display output.
David
SAPIEN Technologies, Inc.
This topic is 6 years and 11 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.