Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用于查询ActiveDirectory的Powershell_Powershell - Fatal编程技术网

用于查询ActiveDirectory的Powershell

用于查询ActiveDirectory的Powershell,powershell,Powershell,(对不起,如果我的英语不好,我是法国人) 我试图在我的广告上自动化一些任务,我正在寻找一个powershell命令,它可以列出过去三个月没有连接的用户。 我尝试使用lastlogontimestamp属性,但无法使其工作。 下面是我的命令的实际外观: $date = new-object System.DateTime -ArgumentList @(2015,8,1,0,0,0) Get-ADUser -Filter { -not (LastLogonTimeStamp -le "$date"

(对不起,如果我的英语不好,我是法国人)

我试图在我的广告上自动化一些任务,我正在寻找一个powershell命令,它可以列出过去三个月没有连接的用户。 我尝试使用lastlogontimestamp属性,但无法使其工作。 下面是我的命令的实际外观:

$date = new-object System.DateTime -ArgumentList @(2015,8,1,0,0,0)
Get-ADUser -Filter { -not (LastLogonTimeStamp -le "$date") }

有什么想法吗?

lastLogonTimestamp
属性存储为表示文件时间时间戳的64位整数

您可以使用将
DateTime
对象转换为此格式

我建议使用而不是
新对象系统。DateTime

# Current time -3 months:
$Threshold = (Get-Date).AddMonths(-3).ToFileTime()

# Retrieve the users
Get-ADUser -LDAPFilter "(&(lastlogontimestamp < $Threshold))"
#当前时间-3个月:
$Threshold=(获取日期).AddMonths(-3).ToFileTime()
#检索用户
获取ADUser-LDAPFilter“(&(lastlogontimestamp<$Threshold))”

(别担心你的英语,反正英语很好)。请尽可能详细地解释您的尝试实际做了什么以及您期望它做什么。我正在尝试识别我可能忘记禁用的帐户。