Powershell获取登陆失败信息
2014-01-21 13:56
288 查看
转自:http://www.pstips.net/finding-logon-failures-2.html
每当用户使用了无效的凭证,将会生成一条安全日志。
下面这个函数实例能读到这些事件从安全日志(注意需要管理员权限),然后显示出所有错误登陆信息。
# requires Admin privileges!
function Get-LogonFailure
{
param($ComputerName)
try
{
Get-EventLog -LogName security -EntryType FailureAudit -InstanceId 4625 -ErrorAction Stop @PSBoundParameters |
ForEach-Object {
$domain, $user = $_.ReplacementStrings[5,6]
$time = $_.TimeGenerated
"Logon Failure: $domain\$user at $time"
}
}
catch
{
if ($_.CategoryInfo.Category -eq 'ObjectNotFound')
{
Write-Host "No logon failures found." -ForegroundColor Green
}
else
{
Write-Warning "Error occured: $_"
}
}
}
注意这个函数也可以远程操作,使用-ComputerName参数去查询远程的电脑. 此时目标的电脑需要开启Remote Registry服务和具有它的本地管理员的权限。
每当用户使用了无效的凭证,将会生成一条安全日志。
下面这个函数实例能读到这些事件从安全日志(注意需要管理员权限),然后显示出所有错误登陆信息。
# requires Admin privileges!
function Get-LogonFailure
{
param($ComputerName)
try
{
Get-EventLog -LogName security -EntryType FailureAudit -InstanceId 4625 -ErrorAction Stop @PSBoundParameters |
ForEach-Object {
$domain, $user = $_.ReplacementStrings[5,6]
$time = $_.TimeGenerated
"Logon Failure: $domain\$user at $time"
}
}
catch
{
if ($_.CategoryInfo.Category -eq 'ObjectNotFound')
{
Write-Host "No logon failures found." -ForegroundColor Green
}
else
{
Write-Warning "Error occured: $_"
}
}
}
相关文章推荐
- 获取当前登陆信息
- PowerShell 学习笔记-- 1 -- 获取帮助信息
- qq登陆及获取头像信息
- PowerShell小技巧之获取域名whois信息
- android腾讯开放平台登陆授权,获取用户信息
- Java登陆3GQQ以及获取好友信息与好友聊天的简单实现
- 使用httpclient4.3.X模拟post请求登陆网站获取cookie信息的操作
- Eclipse获取android更新信息失败的解决问题(换代理服务器)
- 微信公众号开发《一》OAuth2.0网页授权认证获取用户的详细信息,实现自动登陆
- 新浪微博授权登陆获取个人信息
- 垂直发布—Httpclient模拟登陆获取页面信息(一)
- Powershell编程之获取帮助信息
- fopen()失败后获取失败信息
- android studio 加入极光推送 error信息出现获取sdk版本失败的问题
- PowerShell获取Windows用户列表、用户信息的方法
- WCF用户名密码验证——获取准确的用户验证失败异常信息
- PowerShell Function之获取ComputerSystem信息
- [Azure]使用Powershell获取Azure ARM模式订阅下的一些常用信息
- 微信第三方登陆,无需注册一键登录,获取用户信息,PHP实现方法
- Powershell 获取文件版本信息