The term 'new-eventlog' is not recognized as a name of a cmdlet
See original GitHub issuePrerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
execute: New-EventLog -LogName Application -Source "Blah Blah"
Expected behavior
whatever the previous output was in 5.X
Actual behavior
>new-eventlog: The term 'new-eventlog' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Error details
>
Exception :
Type : System.Management.Automation.CommandNotFoundException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : The term 'new-eventlog' is not recognized as a name of a cmdlet, function, script file, or
executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and
try again.
HResult : -2146233087
TargetObject : new-eventlog
CategoryInfo : ObjectNotFound: (new-eventlog:String) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : CommandNotFoundException
InvocationInfo :
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 6
Line : new-eventlog -logname application -source "Blah Blah"
PositionMessage : At line:1 char:1
+ new-eventlog -logname application -source "Blah Blah"
+ ~~~~~~~~~~~~
InvocationName : new-eventlog
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
CommandName : new-eventlog
TargetSite :
Name : LookupCommandInfo
DeclaringType : System.Management.Automation.CommandDiscovery, System.Management.Automation,
Version=7.2.6.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35
MemberType : Method
Module : System.Management.Automation.dll
Message : The term 'new-eventlog' is not recognized as a name of a cmdlet, function, script file, or
executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
Data : System.Collections.ListDictionaryInternal
Source : System.Management.Automation
HResult : -2146233087
StackTrace :
at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes,
SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)
at System.Management.Automation.CommandDiscovery.TryModuleAutoDiscovery(String commandName, ExecutionContext
context, String originalCommandName, CommandOrigin commandOrigin, SearchResolutionOptions searchResolutionOptions,
CommandTypes commandTypes, Exception& lastError)
at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes,
SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)
at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)
at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[]
commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)
at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput,
CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][]
commandRedirections, FunctionContext funcContext)
at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
TargetObject : new-eventlog
CategoryInfo : ObjectNotFound: (new-eventlog:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
InvocationInfo :
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 6
Line : new-eventlog -logname application -source "Blah Blah"
PositionMessage : At line:1 char:1
+ new-eventlog -logname application -source "Blah Blah"
+ ~~~~~~~~~~~~
InvocationName : new-eventlog
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
Environment data
>Name Value
---- -----
PSVersion 7.2.6
PSEdition Core
GitCommitId 7.2.6
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
Shouldn’t that cmdlet work now in 7.x in Windows?
The RFC, Importing Windows PowerShell modules in PowerShell Core, is Final
which means “fully complete and implemented in PowerShell”, right (source)?
Issue Analytics
- State:
- Created a year ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Powershell New-EventLog Error
1 Answer 1 ... You do not have a version of PowerShell that has New-EventLog cmdlet. Run the following to get a list...
Read more >New-EventLog (Microsoft.PowerShell.Management)
Specifies the name of the event log. If the log does not exist, New-EventLog creates the log and uses this value for the...
Read more >Solved: Powershell writing entries to Windows Event logs
New-EventLog : The term 'New-EventLog' is not recognized as the name of a cmdlet, function, script file, or operable program.
Read more >PowerShell Versions
The term 'Write-EventLog' is not recognized as the name of a cmdlet, function, script file, or operable program.
Read more >New event log nowhere to be found after creating in ...
Through PowerShell, I am attempting to create a new event log and write a test entry to it, but it is not showing...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
New-EventLog
is indeed only available in Windows PowerShell.See the conceptual about_Windows_PowerShell_Compatibility help topic.
For in-session use in PowerShell Core (with cross-process serialization behind the scenes), you can make
New-EventLog
available, as follows, but note the limitations discussed in the linked help topic:Note:
-WarningAction Ignore
suppresses two warnings:-AllowClobber
, which isn’t a supported parameter; the real parameter name,-NoClobber
, has the inverse logic and is implied when you use-UseWindowsPowerShell
-SkipEditionCheck
, which would not be effective in this case (leaving aside the fact that it is described as a necessary step, even though (parts of) the module already have been imported).While
3>$null
is usually equivalent to-WarningAction Ignore
/-WarningAction SilentlyContinue
, it fails to suppress the specific warning in this case.In Windows PowerShell.