evotecit / pswritecolor Goto Github PK
View Code? Open in Web Editor NEWWrite-Color is a wrapper around Write-Host allowing you to create nice looking scripts, with colorized output.
License: MIT License
Write-Color is a wrapper around Write-Host allowing you to create nice looking scripts, with colorized output.
License: MIT License
When manually downloading and installing the package, it installs, but then can not be imported (or seen with Get-Module -ListAvailable). This appears to be as the Module Version in the Manifest does not match the folder name. Error message:
`import-module : The ModuleVersion key in module manifest 'C:\Program
Files\WindowsPowerShell\Modules\PSWriteColor\0.85.0\PSWriteColor.psd1' specifies module version '0.85' which does not
match its version folder name at 'C:\Program Files\WindowsPowerShell\Modules\PSWriteColor\0.85.0'. Change the value of
the ModuleVersion key to match the version folder name.
At line:1 char:1
+ CategoryInfo : InvalidArgument: (C:\Program File...WriteColor.psd1:String) [Import-Module], InvalidOper
ationException
+ FullyQualifiedErrorId : Modules_InvalidModuleManifestVersion,Microsoft.PowerShell.Commands.ImportModuleCommand`
Updated LinesBefore & LinesAfter code to make use of these new parameters. Allows for easily formatting menus or table output. See Example code (lines 54-65)
The out-of-the-box alias of wc
for Write-Color
will interfere with the use of the wc
(word count) command on Linux/macOS systems. I would suggest removing it, and letting the user set the alias if they want it.
Could you provide a switch to control the display position, such as the progress bar, the text is only displayed on one line and can be updated. I know that the vt100 control character can realize this function, but I don't know how to modularize it.
It would be even better if the time display function could be integrated.❤️ such as:
write-color "you have waited " -c green -b blue -NoNewLine -NoAppend -ShowClock
$esc=[char]27
$rp="$esc[50G"
$sw=[Diagnostics.StopWatch]::StartNew()
$tm=New-Object System.Timers.Timer
$tm.Interval=1000
Register-ObjectEvent -InputObject $tm -EventName Elapsed -Action {
#$dt=(get-date).tostring("yyyyMMdd HHmmss");
$ep=$sw.Elapsed
#$host.ui.RawUI.WindowTitle = $ep;
write-color "$rp$ep" -C Yellow -B Blue -NoNewline
}|Out-Null
$tm.AutoReset=$true
$tm.Enabled=$true
1..10|foreach-object {$host.ui.RawUI.WindowTitle = $_;start-sleep 1;}
$tm.Enabled=$false
$sw.stop()
read-host "done"
Hi
Great Module ! I'm thinking if it's possible when we're enabling logging to :
generate a log file formated like a .csv. Of course, we should be able to choose the separator (comma is not always the best separator)
You might even consider having additional information : Category (Inf - War, Error)
A single Cmdlet for a pretty console display and a file output that can be used easily later.
There is a module called Ezlog (https://github.com/apetitjean/ezlog), which already does it, but it doesn't have the facilities that Write-Color for console display with several colors in the same text block.
$foo = "Execution Path exists"
Command:`Write-Color "[info] ", $foo -Color Yellow, Yellow -ShowTime`
results in
[2020-09-18 13:27:22] [info] Execution Path exists
New separate lines when using a parameter such as -SplitLines [Separator]
example 1
$foo = "Execution Path exists `n2. Line `n3. Line"
Write-Color "[info] ", $foo -Color Yellow, Yellow -ShowTime` -SplitLines "`n"
results in
[2020-09-18 13:27:22] [info] Execution Path exists
2. Line
3. Line`
example 2
$foo = "Execution Path exists `n2. Line `n3. Line"
`Write-Color "[info] ", $foo -Color Yellow, Yellow -SplitLines "`n"
results in
[info] Execution Path exists
2. Line
3. Line`
Great code but may have a personal issue -
Tried many combinations to get Write-Color to display a $($var)
Typically Write-Host ("Accepts values passed as $(
Help, coffee is running out!
recently, when i try and add a og file, i get extra spaces in it. Any ideas why this could be happening?
the Powershell script has this line:
Write-Colour "##################", " Create Contributor and Reader Security Groups ", "################## " -Color Cyan, Yellow, Cyan -LogFile $Logfile
the output in visual studio shows:
################## Create Contributor and Reader Security Groups ##################
and the log file has this in it:
[ 2 0 2 3 - 0 4 - 2 0 1 6 : 2 0 : 0 2 ] # # # # # # # # # # # # # # # # # # C r e a t e C o n t r i b u t o r a n d R e a d e r S e c u r i t y G r o u p s # # # # # # # # # # # # # # # # # #
Hi,
I'm looking for a way to combine powershell transcript and write-color function.
In PS console, the result is displayed as expected but passing through the transcript each element between "" inserts a new line of the transcript log (between time and text).
Is there a way around this issue without using the -LogFile parameter?
> **********************
> Windows PowerShell transcript start
> Start time: 20210122181054
> Username: xxxxxx
> RunAs User: xxxxx
> Configuration Name:
> Machine: xxxxx
> Host Application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
> Process ID: xxxx
> PSVersion: 5.1.17763.1490
> PSEdition: Desktop
> PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.17763.1490
> BuildVersion: 10.0.17763.1490
> CLRVersion: 4.0.30319.42000
> WSManStackVersion: 3.0
> PSRemotingProtocolVersion: 2.3
> SerializationVersion: 1.1.0.1
> **********************
> [22/01/21 18:10:54]
> Script name : Test-Transcript.ps1
>
> [22/01/21 18:10:54]
> Sed eveniet neque aut rerum perspiciati
>
> [22/01/21 18:10:54]
> voluptas est dolorem error et similique
>
> [22/01/21 18:10:54]
> End script!
>
> [22/01/21 18:10:54]
> Elapsed Time: 0 hours 0 minutes 0 seconds
>
> **********************
> Windows PowerShell transcript end
> End time: 20210122181054
> **********************
Thanks for your help and your work !
When using start-transcript the log files shows, write-color using multiple colors on one line on multiple lines.
Example:
Write-Color "Updating Group: ",$Group -Color Gray,Green -StartTab 1
Output:
Updating Group:
Test Group
Is there a way to fix this issue with start-transcript so one line on write-color will be one line in the transcript file?
Thank you.
Hi !
This module is amazing and I use it in a few of my recent scripts.
I have one question though (not a huge problem I suppose):
When I use this within a script...
...the console output is as intended...
...but if the script is transcripted, the transcript results in line breaks for each color.
Is there any way to add a switch that prevents this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.