GithubHelp home page GithubHelp logo

bvangrinsven / powershellloggingmodule Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dlwyatt/powershellloggingmodule

0.0 1.0 0.0 107 KB

Automatically capture and save PowerShell console output from a script (without the limitations and headaches of Start-Transcript)

License: Apache License 2.0

PowerShell 34.58% C# 65.42%

powershellloggingmodule's Introduction

PowerShellLoggingModule

Uses Reflection to intercept text output headed for the PowerShell console. All lines of output are sent to any number of subscriber objects producing complete log files of script output (adding date/timestamps) without needing extra code by the script author.

The upside is that any text which would have shown up in the console is logged, and the downside is that only that text is logged. For example, verbose output is only logged if VerbosePreference is Continue...

Supports PowerShell 2, 3, 4, 5, 6 and 7

Install from the PowerShell Gallery

Install-Module PowerShellLogging

Compile your own copy

You can compile the assembly with:

dotnet build -c Release

To generate the full module, you can run the build script:

.\build -Version $(gitversion -showvariable nugetversion)

Note: this script builds into a version numbered folder in the module root. The expectation is that you have the source in a folder like ~\Projects\Modules\PowerShellLogging where the parent folder can be added to your PSModulePath for testing purposes, so the build will end up in, e.g.: ~\Projects\Modules\PowerShellLogging\1.4.0 and the build script will update the metadata to make it all versioned properly!

Testing

The test cases are very minimal (basically just covering the fact that it logs, and testing a couple of edge cases where it used to fail to log). Despite that, weand have some problems due to the way that WindowsPowerShell breaks when they fail.

As a result, to be sure that the tests are actually working (reporting the correct results), you should run each test case in a new session. There is a wrapper script test.ps1 which you can use to do that, it basically just runs each test case in PowerShell and pwsh to ensure everything is working in both WindowsPowerShell and PowerShell core. E.g.:

foreach ($testcase in Get-ChildItem Tests\*.Tests.ps1) {
    powershell -NoProfile -Command Invoke-Pester $testcase.FullName
}

Alternative Download

Note, the original version is also available from:

http://gallery.technet.microsoft.com/scriptcenter/Enhanced-Script-Logging-27615f85

powershellloggingmodule's People

Contributors

dlwyatt avatar rbernardino avatar

Watchers

 avatar

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.