Comments (7)
I don't have time to fix this right now. It's on my backlog but in case someone finds time first, I'll add my discovery from a quick email to someone on PowerShell ISE:
"In the console, you have 16 colors via an enum System.ConsoleColor. The names in the enum are mere suggestions, they don’t reflect the user’s choice of RGB values.
For tools that must work in both the console and the ISE, I suggest sticking to using System.ConsoleColor instead of a real color type like System.Windows.Media.Color. You can map the ConsoleColor back to another color type as needed in host specific code, or you can stick with PowerShell cmdlets that only know about ConsoleColor (like Write-Host) and avoid host issues like this."
from virtualization-documentation.
The problem here is that the user cannot change the variable stored in the ISE host's PrivateData.ErrorForegroundColor variable:
PS C:\Users\daviwil> (Get-Host).PrivateData.ErrorForegroundColor = [System.ConsoleColor]::Red
Exception setting "ErrorForegroundColor": "Cannot convert value "Red" to type
"System.Windows.Media.Color". Error: "Invalid cast from 'System.ConsoleColor' to
'System.Windows.Media.Color'.""
At line:1 char:1
+ (Get-Host).PrivateData.ErrorForegroundColor = [System.ConsoleColor]:: ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], SetValueInvocationException
+ FullyQualifiedErrorId : ExceptionWhenSetting
This is definitely a consequence of the ISE using WPF colors, but this makes sense because the ISE's host needs to write output to a WPF control and the user has the ability to change these colors in their settings.
I'd recommend using Write-Error instead of writing errors in your own way. This will cause the right output color to be used in any PowerShell host regardless of what form it's stored in.
from virtualization-documentation.
I guess the bigger question is why any of the Write-W2Vxxxxxx functions even exist (Write-W2VError, Write-W2VTrace,Write-W2VWarning,Write-W2VInfo), rather than just using Write-Error, Write-Verbose, Write-Warning, and Write-Host. I was trying to look through to see if there was some sort of tee- or transcript-writing combo or something, but I didn't find the reasoning. It seems like a find/replace of Write-W2Vxxx with their native equivalents would remove the need for all of those functions.
from virtualization-documentation.
Agreed - these wrapper functions are historical artefacts. IIRC, Artem was going to work on this.
from virtualization-documentation.
@pronichkin will address this one
from virtualization-documentation.
Thanks Mike,
Pardon my ignorance, but I’m really new to all this GitHub stuff. Do I need to do something special to get access to this project? Or to be listed as an official Microsoft contributor?
From: Mike Ebersol [mailto:[email protected]]
Sent: Friday, February 12, 2016 10:22 PM
To: Microsoft/Virtualization-Documentation [email protected]
Cc: Artem Pronichkin [email protected]
Subject: Re: [Virtualization-Documentation] Convert-WindowsImage Write-W2VError doesn't work in ISE due to conversion of the color (#137)
@Pronichkinhttps://github.com/Pronichkin will address this one
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/137#issuecomment-183456434.
from virtualization-documentation.
Closing issue due to lack of activity.
from virtualization-documentation.
Related Issues (20)
- VMConnect dynamic resize only works for Windows guests
- haxm
- Link to Windows Server containers roadmap is dead
- Please provide troubleshooting info HOT 1
- SMB access
- cihad HOT 3
- awdawD
- cio
- Add Support for Emulating Pre-Populated Volumes
- Add more notes on DNS failure on the host machine immediately after creating a new external virtual switch
- "Use a script to install Docker EE" link is broken HOT 1
- Running powershell script to install Docker CE HOT 1
- hyper-V
- linked post inlcude instructions that no longer work HOT 1
- Missing requirements?
- feedback - powershell docker install
- a
- Containers extension gone with WAC preview?
- HostProcess Containers
- Deleting Checkpoints, more details
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from virtualization-documentation.