对参数集的理解

就拿 get-evenlog 做示例:


PS [LAPTOP-N7AS0BS5] >help Get-EventLog

名称
    Get-EventLog

摘要
    Gets the events in an event log, or a list of the event logs, on the local computer or remote compu
    ters.


语法
    Get-EventLog [-LogName] <System.String> [[-InstanceId] <System.Int64[]>] [-After <System.DateTime>]
     [-AsBaseObject] [-Before <System.DateTime>] [-ComputerName <System.String[]>] [-EntryType {Error |
     Information | FailureAudit | SuccessAudit | Warning}] [-Index <System.Int32[]>] [-Message <System.
    String>] [-Newest <System.Int32>] [-Source <System.String[]>] [-UserName <System.String[]>] [<Commo
    nParameters>]

    Get-EventLog [-AsString] [-ComputerName <System.String[]>] [-List] [<CommonParameters>]

显然他有两个参数集,由于powershell版本的不同同一命令会有更多的功能,参数也就更多了。

使用powershell,就是输入一个命令然后通过贴加一些参数来定制化命令行为。

试试不给必选参数赋值:

PS [LAPTOP-N7AS0BS5] >Get-EventLog

位于命令管道位置 1 的 cmdlet Get-EventLog
请为以下参数提供值:
LogName:

所以说最后还是得赋值

猜你喜欢

转载自blog.csdn.net/qq_52317104/article/details/120913164