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
Windows Active directory-带筛选器的Powershell 90天_Windows_Powershell_Active Directory_Export_Days - Fatal编程技术网

Windows Active directory-带筛选器的Powershell 90天

Windows Active directory-带筛选器的Powershell 90天,windows,powershell,active-directory,export,days,Windows,Powershell,Active Directory,Export,Days,我有一些代码可以从Active directory中的特定位置导出90天未登录的所有帐户,并将它们导出到电子表格中 我们有一些账户是为延长休假的人提供的,所以我们不想列出这些账户。之前,我们使用一个利用“comment”属性的过滤器过滤掉这些内容,当其中有一个“el”时,它会忽略这些内容 你能告诉我如何将这个过滤器添加到下面的代码中吗 $Date=get-date $Days=90 $DIR='TEST.test.uk/TEST/Users & Desktops/NormalUs

我有一些代码可以从Active directory中的特定位置导出90天未登录的所有帐户,并将它们导出到电子表格中

我们有一些账户是为延长休假的人提供的,所以我们不想列出这些账户。之前,我们使用一个利用“comment”属性的过滤器过滤掉这些内容,当其中有一个“el”时,它会忽略这些内容

你能告诉我如何将这个过滤器添加到下面的代码中吗

$Date=get-date    
$Days=90
$DIR='TEST.test.uk/TEST/Users & Desktops/NormalUsers'

Get-QADUser -SearchRoot $DIR -sizeLimit 0 | where {
$_.lastlogontimestamp -and
(($Date-$_.lastlogontimestamp).days -gt $Days) 
} | Select-Object logonName, DisplayName, Comment | export-csv users90.csv
我曾尝试在where中添加
$\注释-ne“el”-和
,但没有效果


请帮忙

您无法筛选不存在的内容
$\注释
很可能为空,因为它不包括在Get QADUser的默认属性集中。从中可以看出,您需要使用
-IncludedProperties注释

Get-QADUser -SearchRoot $DIR -sizeLimit 0 -IncludedProperties Comment

现在,您的
Where对象
子句应该按预期工作。不确定要调用的其他属性,但您始终可以使用
Get QADPSSnapinSettings

检查默认列表,您是指描述字段吗?另外,如果“el”只是一个前缀,您可以使用
-而不是像“el*”
那样没有Quest cmdlet,但默认情况下它们可能不会返回注释。在
Get ADUSer
中,您需要指定默认属性之外的属性,如
Get ADUSer-properties Comment
No,而不是description。在广告记录的属性编辑器选项卡中,有一个名为“Comment”的属性。由于旧系统的原因,它是这样的,因此必须使用它而不是description。这很好。我只是以前从未见过有人使用它,所以我想澄清一下。我想您需要使用
-IncludeProperties Comment
来处理您的cmdlete正是我想要的,我怎么会错过像include这样简单的东西呢。为快速响应干杯。@很高兴我能帮忙。你可以考虑将答案标记为被接受来帮助社区。