因此,我正在努力编写此脚本,该脚本应该获得上次使用客户端的时间,PC的序列号和名称。今天我已经问过一个关于Get-WmiObject遇到的问题的问题,但是一位非常有帮助的评论员告诉我,可能有更好的方法来解决此问题。
因此,在上一次尝试中,我的主要问题是“ RPC不可用”错误消息的数量以及该命令对每个客户端所需的时间。
$Computers = Get-ADComputer -filter * |
Select-Object -first 1 |
Select-Object -expandProperty Name
write-host $computers
foreach ($name in $computers) {
Get-WmiObject -Class win32_process -ComputerName $name | Where-Object {
$_.name -Match "explorer*"
} | ForEach-Object {
@{ PC = $name; User = $_.getowner().user}
} | Out-GridView
}
我也尝试过
Get-ChildItem "\\$computers\c$\Users"
| Sort-Object LastWriteTime -Descending
| Select-Object Name, LastWriteTime -first 1 | Out-GridView
有时有效,但并非总是如此。
我还尝试使用EventLog尝试执行命令,导致上次登录日期不准确。
感谢您的帮助,请多多包涵我,我对此仍然很陌生