powershell - 查看最近的远程 powershell 连接
问题描述
在计算机上启动远程 pssession 时是否会生成某种事件日志?我需要能够查看远程会话的来源。
目前我正在跑步
Get-EventLog -LogName "Windows powershell" -newest 100 | Format-List -Property * | where {$_.UserID -eq "username"}
但它没有过滤和/或显示远程连接。
解决方案
我们在这里帮助您解决代码问题。这实际上不是代码问题,而是了解如何设置以及在何处关联这些细节。因此,这可能是另一个论坛的问题。
无论如何,为了让您接近您所追求的,您需要采取额外的步骤来获取此类信息。稍后再谈。
现在,一旦您完成所有设置并编写脚本以提取/查看此类信息并且您遇到问题,然后将其发布回此处以供人们查看可以做什么
因此,这将我们引向这里:有三个通用的日志记录区域:
• 模块日志记录 • 脚本块日志记录 • PowerShell 转录
如果您还没有这样做,我建议您启用 PS 审计和脚本日志记录,以便更深入地了解此用例和脚本日志记录(可以捕获在主机上执行的所有命令/代码)。如果您正确设置了所有这些,您首先查看脚本日志以获取详细信息,并查看您在帖子中引用的日志名称以获取其他详细信息。
通过 GPO 或 DSC 设置此企业范围。
有很多关于如何设置的指导。
例如:
使用转录和日志记录审核 PowerShell 使用情况
Get-Command -Name '*transcript*'
CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Get-TRSTranscriptionJob 3.3.234.0 AWSPowerShell
Cmdlet Get-TRSTranscriptionJobList 3.3.234.0 AWSPowerShell
Cmdlet Start-Transcript 3.0.0.0 Microsoft.PowerShell.Host
Cmdlet Start-TRSTranscriptionJob 3.3.234.0 AWSPowerShell
Cmdlet Stop-Transcript 3.0.0.0 Microsoft.PowerShell.Host
https://docs.microsoft.com/en-us/powershell/wmf/5.0/audit_overview
实用的 PowerShell 安全性:使用 DSC 启用审计和日志记录
PowerShell V5 中的更多新内容:额外的 PowerShell 审计
Get-Module Microsoft.* | Select Name, LogPipelineExecutionDetails
Get-Module Microsoft.* | ForEach { $_.LogPipelineExecutionDetails = $True }
(Import-Module ActiveDirectory).LogPipelineExecutionDetails = $True
Get-WinEvent -FilterHashtable @{LogName='Windows PowerShell';Id ='800'} -MaxEvents 1 | Select -Expand Message
https://learn-powershell.net/2014/08/26/more-new-stuff-in-powershell-v5-extra-powershell-auditing
调查 PowerShell:命令和脚本日志记录
https://www.crowdstrike.com/blog/investigating-powershell-command-and-script-logging
推荐阅读
- cmake - 同时运行多个构建系统进程
- python - Python 和 Hidapi:尝试编写 USB 设备时出现参数错误
- azure - 将 Azure AD 与另一个身份提供商同步
- prolog - 在 Prolog 中查找断开连接的子图
- c - Scanf 在使用“%c%c”时不读取换行符
- java - 我在播放在线广播流时收到异常
- javascript - 如何将 Echarts 中的工具提示添加到雷达指标
- python - Robotframework-rabbitmq 不能与最新的机器人框架库一起使用
- laravel - 如何从使用 Passport 作为 Web Guard 的 Laravel Web 应用程序获取访问令牌以用于 Gatling 负载测试
- jmeter - 请求的资源不允许用POST请求请求数据,或者请求中提供的数据量超过了inn Jmeter工具的容量限制