计算机后台数据分析(扫描域中长期不登录的计算机)

 2025-10-01  阅读 919  评论 0

摘要:领导今天让Disable所有域中超过60天没登录的计算机和账号,我先搜索出一篇文章,是查询 计算机的,稍后再操作AD账号的。下面是原贴,是英文,我加上了我自己的翻译。使用PowerShell命令查询Active Directory中长时间没有登录计算机帐户。本文章以60天为例,大家可以根据需要修改。

领导今天让Disable所有域中超过60天没登录的计算机和账号,我先搜索出一篇文章,是查询 计算机的,稍后再操作AD账号的。下面是原贴,是英文,我加上了我自己的翻译。

使用PowerShell命令查询Active Directory中长时间没有登录计算机帐户。本文章以60天为例,大家可以根据需要修改。

下面给出脚本:

# This PowerShell Command will query Active Directory and return the computer accounts which have not logged for the past

#这个PowerShell命令将会查询 并返回AD域中过去一段时间没有登录的电脑账号

# 60 days. You can easily change the number of days from 60 to any number of your choosing. lastLogonDate is a Human

#你可以改变下面的那个60的参数来查询是多少天未登录的

# Readable conversion of the lastLogonTimeStamp (as far as I am able to discern. More details about the timestamp can

$then = (Get-Date).AddDays(-60) # The 60 is the number of days from today since the last logon.

#这个60就是从上次登录到今天60天,你可以改变这个参数

Get-ADComputer -Property Name,lastLogonDate -Filter {lastLogonDate -lt $then} | FT Name,lastLogonDate

#这一行就是关键命令了,可以直接复制,查询出列表

# If you would like to Disable these computer accounts, uncomment the following line:

#如果你想禁用那些电脑账号,可以把下面这行命令的"#"删除即可

# Get-ADComputer -Property Name,lastLogonDate -Filter {lastLogonDate -lt $then} | Set-ADComputer -Enabled $false

# If you would like to Remove these computer accounts, uncomment the following line:

#如果你想删除这些电脑账号,直接去年下面命令的"#"

# Get-ADComputer -Property Name,lastLogonDate -Filter {lastLogonDate -lt $then} | Remove-ADComputer

我还想补充的一点是,上面的命令要在PowerShell里面运行,PowerShell还要用管理员的模式打开,下面是我运行的截图。

计算机后台数据分析(扫描域中长期不登录的计算机)(1)

计算机后台数据分析(扫描域中长期不登录的计算机)(2)

,

版权声明:xxxxxxxxx;

原文链接:http://cn.tdroid.net/ced73Cz0HCgEEUVw.html

发表评论:

管理员

  • 内容298022
  • 积分0
  • 金币0
关于我们
lecms主程序为免费提供使用,使用者不得将本系统应用于任何形式的非法用途,由此产生的一切法律风险,需由使用者自行承担,与本站和开发者无关。一旦使用lecms,表示您即承认您已阅读、理解并同意受此条款的约束,并遵守所有相应法律和法规。
联系方式
电话:
地址:广东省中山市
Email:
注册登录
注册帐号
登录帐号

Copyright © 2022 太卓开发网 Inc. 保留所有权利。 泰达科技网易库网

页面耗时0.1259秒, 内存占用1.33 MB, 访问数据库18次