Skip to content

PowerShell 7 - Enable-LogFile: Object reference not set to an instance of an object. #9

Open

Description

@mlueckert

Dear All

When trying to use the module in PowerShell 7 I get the following error.

C:\> import-module PowerShellLogging
C:\> Enable-LogFile -Path "c:\temp\test.txt"

ErrorCallback Path             Streams DateTimeFormat
------------- ----             ------- --------------
              C:\temp\test.txt     All r
Enable-LogFile: Object reference not set to an instance of an object.

Thank you very much.
Marc

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
get-module -Name PowerShellLogging
                                                                                
ModuleType Version    PreRelease Name                                ExportedCom
---------- -------    ---------- ----                                -----------
Script     1.3.0                 PowerShellLogging                   {Disable-Lo

Activity

  1. bm3n commented on Nov 10, 2020

    @bm3n

    After upgrading from PS 5.1 to 7.0.3 logging stopped working with the same error reported above.

    Here's the stack trace:

    Object reference not set to an instance of an object.
       at PSLogging.HostIOInterceptor.AttachToHost(PSHost host)
       at PSLogging.Commands.EnableLogFileCommand.EndProcessing()
       at System.Management.Automation.CommandProcessorBase.Complete()
    
    $PSVersionTable
    
    Name                           Value
    ----                           -----
    PSVersion                      7.0.3
    PSEdition                      Core
    GitCommitId                    7.0.3
    OS                             Microsoft Windows 6.3.9600
    Platform                       Win32NT
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0.}
    PSRemotingProtocolVersion      2.3
    SerializationVersion           1.1.0.1
    WSManStackVersion              3.0
    
    Get-Module -Name PowerShellLogging
    
    ModuleType Version    PreRelease Name                                ExportedCommands
    ---------- -------    ---------- ----                                ----------------
    Script     1.3.0                 PowerShellLogging                   {Disable-LogFile, Disable-OutputSubscriber, Enabl.
    
  2. Jaykul commented on Aug 7, 2021

    @Jaykul

    This has been fixed in source for a long time. You'll just have to build your own copy 😕

  3. acr-varonis commented on Jan 22, 2023

    @acr-varonis

    @Jaykul it would be nice to have a new version in the gallery.

  4. DennisL68 commented on Dec 11, 2023

    @DennisL68

    @dlwyatt, @rbernardino
    When will a new version be released to PS Gallery?

  5. Jaykul commented on Dec 16, 2023

    @Jaykul

    I'd have to fork it, I think. Not sure I can take over someone else's module in the gallery.

  6. dlwyatt commented on Dec 16, 2023

    @dlwyatt
    Owner

    Is your username just @Jaykul in psgallery? I can add you as an owner there. I haven't used or tested this thing in ages :)

  7. Jaykul commented on Dec 16, 2023

    @Jaykul

    Can you transfer the project to the PoshCode and add me there too, so I can deal with issues?
    Oh, and yes -- and the account is connected to my email at huddledmasses.org still.

  8. dlwyatt commented on Dec 16, 2023

    @dlwyatt
    Owner

    You can fork the git repo, no need to move that. I just added you as an owner in psgallery so you can publish new stuff :)

  9. dlwyatt commented on Dec 16, 2023

    @dlwyatt
    Owner

    feel free to update the links on psgallery to point to a new location for the project site, but I'd rather keep my old projects here. Might need the resume material someday lol.

  10. Jaykul commented on Dec 16, 2023

    @Jaykul

    Yeah, that's fine. I'll swap it. It's just that actual fork repos can't have issues. But I'll deal with it ;)

  11. DennisL68 commented on Jan 16, 2024

    @DennisL68

    @Jaykul and @dlwyatt, any updates on the Source Code transfer and publication update on PS Gallery?

  12. DennisL68 commented on Feb 10, 2025

    @DennisL68

    @Jaykul Good to see that you've got the shared ownership over at PS Gallery 👍

    Now, you actually don't need to fork this repo. You could do a "dirty hijack" by starting a clean project instead (maybe with another name) here at GitHub with an uninitialized repo, and then just push a local git clone of this repo to that remote instead.

    Then this repo would just have to be marked abandoned and a manual link entered in this ReadMe to the new project.

  13. DennisL68 commented on Jun 2, 2025

    @DennisL68

    @Jaykul Did we get a new repo of this project or how was this handled?

  14. Jaykul commented on Jun 2, 2025

    @Jaykul

    Oh, yes. I put it in the PoshCode org:
    https://github.com/PoshCode/PowerShellLogging

  15. Spectrum1981 commented on Sep 15, 2025

    @Spectrum1981

    This has been fixed in source for a long time. You'll just have to build your own copy 😕

    Hi!

    I have the Same issue now. How can I build my own copy? Is there a manual?

    Thank you!

  16. Jaykul commented on Sep 21, 2025

    @Jaykul

    There are simple directions in the readme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions