查看最近的远程 powershell 连接
View recent remote powershell connections
是否有在计算机上启动远程 pssession 时生成的某种事件日志?我需要能够查看远程会话的来源。
目前我是运行
Get-EventLog -LogName "Windows powershell" -newest 100 | Format-List -Property * | where {$_.UserID -eq "username"}
但它没有过滤 and/or 显示远程连接。
我们在这里帮助您解决代码问题。这实际上不是代码问题,而是了解如何设置以及在何处关联此类细节。所以,这可能是另一个论坛的问题。
无论如何,为了让您接近您所追求的目标,您需要采取额外的步骤来获取此类信息。稍后会详细介绍。
现在,一旦你完成所有设置并编写脚本来提取/查看此类信息并且你遇到了问题,然后 post 回到这里让人们看看可以做什么
因此,这将我们带到这里:
可用于日志记录的三个常规区域:
• 模块记录
• 脚本块记录
• PowerShell 转录
如果您还没有这样做,我建议您启用 PS 审计和脚本日志记录,以便更深入地了解这个用例以及脚本日志记录(它可以捕获在主机上执行的所有命令/代码机器)。如果您正确设置了所有这些,您首先查看转录日志以获取详细信息,并查看您在 post 中引用的日志名称以获取其他详细信息。
通过 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
是否有在计算机上启动远程 pssession 时生成的某种事件日志?我需要能够查看远程会话的来源。
目前我是运行
Get-EventLog -LogName "Windows powershell" -newest 100 | Format-List -Property * | where {$_.UserID -eq "username"}
但它没有过滤 and/or 显示远程连接。
我们在这里帮助您解决代码问题。这实际上不是代码问题,而是了解如何设置以及在何处关联此类细节。所以,这可能是另一个论坛的问题。
无论如何,为了让您接近您所追求的目标,您需要采取额外的步骤来获取此类信息。稍后会详细介绍。
现在,一旦你完成所有设置并编写脚本来提取/查看此类信息并且你遇到了问题,然后 post 回到这里让人们看看可以做什么
因此,这将我们带到这里: 可用于日志记录的三个常规区域:
• 模块记录 • 脚本块记录 • PowerShell 转录
如果您还没有这样做,我建议您启用 PS 审计和脚本日志记录,以便更深入地了解这个用例以及脚本日志记录(它可以捕获在主机上执行的所有命令/代码机器)。如果您正确设置了所有这些,您首先查看转录日志以获取详细信息,并查看您在 post 中引用的日志名称以获取其他详细信息。
通过 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