PowerShellLoggingModule icon indicating copy to clipboard operation
PowerShellLoggingModule copied to clipboard

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

Open mlueckert opened this issue 5 years ago • 16 comments

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

mlueckert avatar Mar 11 '20 08:03 mlueckert

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.

bm3n avatar Nov 10 '20 19:11 bm3n

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

Jaykul avatar Aug 07 '21 04:08 Jaykul

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

acr-varonis avatar Jan 22 '23 13:01 acr-varonis

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

DennisL68 avatar Dec 11 '23 22:12 DennisL68

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

Jaykul avatar Dec 16 '23 04:12 Jaykul

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 :)

dlwyatt avatar Dec 16 '23 04:12 dlwyatt

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.

Jaykul avatar Dec 16 '23 05:12 Jaykul

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 :)

dlwyatt avatar Dec 16 '23 05:12 dlwyatt

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.

dlwyatt avatar Dec 16 '23 05:12 dlwyatt

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 ;)

Jaykul avatar Dec 16 '23 05:12 Jaykul

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

DennisL68 avatar Jan 16 '24 12:01 DennisL68