【问题标题】:Powershell command line logs - what is 'prompt'Powershell 命令行日志 - 什么是“提示”
【发布时间】:2016-05-28 14:17:23
【问题描述】:

为 powershell 拉取命令行日志,我们添加了变量

#$LogCommandHealthEvent = $true
#$LogCommandLifeCycleEvent = $true

而且效果很好,但什么是“提示”??

Time                 Event Command    
----                 ----- -------    
5/27/2016 1:38:31 PM   501 prompt     
5/27/2016 1:38:31 PM   500 prompt     
5/27/2016 1:38:31 PM   501 get-process
5/27/2016 1:38:31 PM   500 get-process
5/27/2016 1:38:29 PM   501 prompt     
5/27/2016 1:38:29 PM   500 prompt     
5/27/2016 1:38:29 PM   501 ipconfig   

这确实出现在日志的事件数据中 - faa69d45087e PipelineId=608 CommandName=prompt CommandType=Function ScriptName= CommandPath= CommandLine=prompt

【问题讨论】:

  • prompt 是负责生成提示的函数。
  • 所以我们想要监控任何人(尤其是坏人)何时从 powershell 运行命令。是否每次从命令行运行命令时都会调用提示函数?
  • 每次 PowerShell 显示 PS C:\> 或任何路径时都会调用它。这是在交互式会话期间实际执行此操作的功能。否则,你只会得到一个闪烁的光标。您可以通过查看 Get-Item Function:\prompt | Select-Object -ExpandProperty Definition 来了解它的作用。
  • 这也是您可以定义自定义提示的方法。

标签: powershell logging


【解决方案1】:

来自About_Prompts

Prompt 函数确定 Windows PowerShell 的外观 迅速的。 Windows PowerShell 带有一个内置的提示功能,但 您可以通过定义自己的 Prompt 函数来覆盖它。 ... 内置提示 Windows PowerShell 包括一个内置的提示功能。 在 Windows PowerShell 3.0 中,内置的提示功能是:
    function prompt
    {
        "PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) "
    }

其他细节:

  1. 每次显示提示时都会调用提示函数来刷新提示的任何细节(例如路径)。

【讨论】:

    猜你喜欢
    • 2022-08-03
    • 1970-01-01
    • 2011-02-04
    • 2014-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-07
    相关资源
    最近更新 更多