Giter Site home page Giter Site logo

evotecit / pswritecolor Goto Github PK

View Code? Open in Web Editor NEW
155.0 11.0 26.0 87 KB

Write-Color is a wrapper around Write-Host allowing you to create nice looking scripts, with colorized output.

License: MIT License

PowerShell 100.00%
powershell write-color write-host color write-output wrapper hacktoberfest

pswritecolor's Issues

NuGet package does not install properly (v.0.85.0)

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

  • import-module 'C:\Program Files\WindowsPowerShell\Modules\PSWriteColo ...
  •   + CategoryInfo          : InvalidArgument: (C:\Program File...WriteColor.psd1:String) [Import-Module], InvalidOper
     ationException
      + FullyQualifiedErrorId : Modules_InvalidModuleManifestVersion,Microsoft.PowerShell.Commands.ImportModuleCommand`
    

show text like a progressbar

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"

abc

Improvment

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.

request: support multiline split with separator

$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`

Doesn't seem to accept parameters when passed

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 $($suchhere)") but cannot seem to make this happen here. The ( )s outside of the "" quotes help display $($vars) but no combo in our out of quotes like write-color "(" text $($var) ")" or (" text $($var) ") work.

Help, coffee is running out!

Extra Spaces in Log Files

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 # # # # # # # # # # # # # # # # # #

Transcript with Write-Color

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?

firefox_2021-01-22_18-16-21


> **********************
> 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 !

write-color transcript output showing up on different lines

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.

Output is multiple line in transcript

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...
image

...the console output is as intended...
image

...but if the script is transcripted, the transcript results in line breaks for each color.
image

Is there any way to add a switch that prevents this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.