-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Misordering in the parameter set of Get-EventLog command #27128
Description
Prerequisites
- 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
Summary help about the command Get-EventLog lists the syntax of the command. The syntax does not order the positional parameters first (in their respective positions) and then the Named parameters; but instead the section does so in alphabetical order. It is especially confusing to the less experienced users because the positional parameter InstanceId gets ordered before the positional parameter LogName, however LogName (position 0) must be before InstanceId (position 1). Similar misordering is also observed in Write-EventLog and such.
However, online documentation (https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-eventlog?view=powershell-5.1&viewFallbackFrom=powershell-7.6) for the cmdlet is fine. Also there is another problem with the syntax of Get-EventLog when viewed from Get-Command, that is, Get-Command -Name 'Get-EventLog' -Syntax says that type of argument of every parameter of Get-EventLog is a generic Object instead of being specific. Furthermore, the Parameter parameter of Get-Help does not work with Get-EventLog too.
Expected behavior
PS> Get-Help -Name 'Get-EventLog'
NAME
Get-EventLog
SYNOPSIS
Gets the events in an event log, or a list of the event logs, on the local computer or remote
computers.
SYNTAX
Get-EventLog [-LogName] <System.String> [[-InstanceId] <System.Int64[]>] [-ComputerName <Sytem.String[]>] [-Newest
<System.Int32>] [-After <System.DateTime>] [-Before <System.DateTime>] [-UserName <System.String[]>] [-Index
<System.Int32[]>] [-EntryType <System.String[]>] [-Source <System.String[]>] [-Message <System.String>]
[-AsBaseObject <System.Management.Automation.SwitchParameter>] [<CommonParameters>]
Get-EventLog [-ComputerName <System.String[]>] [-List <System.Management.Automation.SwitchParameter>] [-AsString
<System.Management.Automation.SwitchParameter>] [<CommonParameters>]
...Actual behavior
PS> Get-Help -Name 'Get-EventLog'
NAME
Get-EventLog
SYNOPSIS
Gets the events in an event log, or a list of the event logs, on the local computer or remote
computers.
SYNTAX
Get-EventLog [-After <System.DateTime>] [-AsBaseObject <System.Management.Automation.SwitchParameter>] [-Before
<System.DateTime>] [-ComputerName <System.String[]>] [-EntryType <System.String[]>] [-Index <System.Int32[]>]
[[-InstanceId] <System.Int64[]>] [-LogName] <System.String> [-Message <System.String>] [-Newest <System.Int32>]
[-Source <System.String[]>] [-UserName <System.String[]>] [<CommonParameters>]
Get-EventLog [-AsString <System.Management.Automation.SwitchParameter>] [-ComputerName <System.String[]>] [-List
<System.Management.Automation.SwitchParameter>] [<CommonParameters>]
...Error details
Environment data
PS> $PSVersionTable
Name Value
---- -----
PSVersion 7.6.0
PSEdition Core
GitCommitId 7.6.0
OS Microsoft Windows 10.0.26200
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.4
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
No response