windows – 从Get-WinEvent获取用户名
发布时间:2020-12-14 02:01:22 所属栏目:Windows 来源:网络整理
导读:我试图找到一个在服务器上卸载程序的用户.这是我正在使用的脚本和结果.从事件查看器,我能够看到用户,但看起来像Get-WinEvent返回UserId但没有用户名.有没有办法从Get-WinEvent返回事件1034的用户名? Get-WinEvent -FilterHashtable @{LogName='Application'
我试图找到一个在服务器上卸载程序的用户.这是我正在使用的脚本和结果.从事件查看器,我能够看到用户,但看起来像Get-WinEvent返回UserId但没有用户名.有没有办法从Get-WinEvent返回事件1034的用户名?
Get-WinEvent -FilterHashtable @{LogName='Application'; Id=1034} -MaxEvents 1 | format-list TimeCreated : 6/17/2013 1:41:27 PM ProviderName : MsiInstaller Id : 1034 Message : Windows Installer removed the product. Product Name: PAL. Product Version: 2.3.2. Product Language: 1033. Manufacturer: PAL. Removal success or error status: 0. 解决方法
使用.NET的
SecurityIdentifier,as described here.
Get-WinEvent -MaxEvents 1000 | foreach { $sid = $_.userid; if($sid -eq $null) { return; } $objSID = New-Object System.Security.Principal.SecurityIdentifier($sid); $objUser = $objSID.Translate([System.Security.Principal.NTAccount]); Write-Host $objUser.Value; } 对于非空用户ID,我能够成功识别用户名. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 如何“安装”自定义Windows驱动程序?
- win10 vscode使用 智能提示
- windows-phone-7 – 在windows phone 7中以编程方式打开离线
- WSUS与Windows 10和Windows 10 GDR-DU产品之间的区别
- Windows上有.Net的Valgrind相当吗?
- windows – GnuTLS:无法使用GIT_SSH_COMMAND获取随机数据
- 如何使用PowerShell在Hyper-V上获取Windows 2008 R2 VM的IP
- windows – 我可以使用powershell强制执行密码套件
- Windows系统故障排查
- windows – 为什么在IIS中添加其他应用程序池?