powershell - 如何列出特定计算机上的登录?
问题描述
我必须编写一个简单的脚本,列出在特定 OU 中的每台计算机上登录的所有用户。
我已经尝试过这个函数Get-UserLogon -OU '[distinguished name]'
(见这里),但它没有返回任何标准输出。
有什么选择吗?
解决方案
您是否尝试过为您的用户提供上次登录时间和日期:
Get-ADUser -Filter * -SearchBase "ou=users,dc=contoso,dc=local" -ResultPageSize 0 -Prop CN,lastLogonTimestamp | Select CN,@{n="lastLogonDate";e={[datetime]::FromFileTime($_.lastLogonTimestamp)}} | Export-CSV -NoType last.csv
推荐阅读
- javascript - php文件不会加载ajax请求
- java - Android SpeechRecorder 实时语音到 EditText 中的文本预览
- c++ - 如何通过stbi_write_png保存高清图片
- python - 将字母和数字的字符串转换为数组
- arrays - 为什么数组吞下的元素多于其容量?
- random - 为什么这个 rand use 语句在 rust 中起作用?
- node.js - UnhandledPromiseRejectionWarning:TypeError:无法读取未定义的属性“缓冲区”
- css - 如何在保持精确的 div 比率的同时阻止文本溢出到另一个 div?
- angular - 如何在 TypeScript 中正确使用 GeolocationPosition?
- html - 使用 BeautifulSoup 抓取非内联样式的 html 元素的 css 属性