windows – 上次知道的计算机登录

我一直在使用以下命令输出为退役设置的计算机列表的最后一次已知登录.该脚本可以工作,但仅适用于当前登录的DC.如何让它循环遍历网络中的所有DC.

Get-ContentC:\noresponse.csv|Foreach-Object{Get-ADComputer$_-PropertiesLastlogonDate}|SortLastlogonDate|FTName,LastlogonDate-Autosize|Out-FileC:\TempComputerLastlogonDa

根据您现有的PS,您需要一些东西来帮助确定AD中的旧计算机.

你可以运行PS here

# Gets time stamps for all computers in the domain that have NOT logged in since after specified date 
# Mod by Tilo 2013-08-27 
import-module activedirectory  
$domain = "domain.mydom.com"  
$DaysInactive = 90  
$time = (Get-Date).Adddays(-($DaysInactive)) 

# Get all AD computers with lastlogonTimestamp less than our time 
Get-ADComputer -Filter {LastlogonTimeStamp -lt $time} -Properties LastlogonTimeStamp | 

# Output hostname and lastlogonTimestamp into CSV 
select-object Name,@{Name="Stamp"; Expression={[DateTime]::FromFileTime($_.lastlogonTimestamp)}} | export-csv OLD_Computer.csv -notypeinformation

或者我个人长期以来最喜欢的JoeWare:

http://www.joeware.net/freetools/tools/oldcmp/

相关文章

Windows2012R2备用域控搭建 前置操作 域控主域控的主dns:自...
主域控角色迁移和夺取(转载) 转载自:http://yupeizhi.blo...
Windows2012R2 NTP时间同步 Windows2012R2里没有了internet时...
Windows注册表操作基础代码 Windows下对注册表进行操作使用的...
黑客常用WinAPI函数整理之前的博客写了很多关于Windows编程的...
一个简单的Windows Socket可复用框架说起网络编程,无非是建...