且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

自90天以来根据自定义属性值删除已禁用的帐户

更新时间:2023-12-05 12:33:22

该错误表明您正在尝试执行该属性不接受的操作.当您在较早的操作中填充该字段时,将日期转换为带有 @ {extensionAttribute4 ="$ timer"} 的字符串.我无法想象那些属性无论如何都存储为字符串以外的任何其他内容.实际上,尝试存储日期对象会以类似的失败告终.

The error indicates you are trying to do an operation that the attribute does not accept. When you populated the field in your earlier operation you converted the date to a string with @{extensionAttribute4="$timer"}. I can't imagine those attributes are stored as anything other than strings anyway. In fact trying to store the date object ends in similar failure.

使用 -Filter 的荣誉,但是我敢肯定这是 -Filter / -LDAPFilter 以外的东西,因此您只需要做一些后期处理.

Kudos for using -Filter but I am sure this is something beyond the -Filter/-LDAPFilter so you should just have to do some post processing.

Get-ADUser -Filter {enabled -eq $false} -SearchBase "OU=Disabled Accounts,DC=domain,DC=lan" -Properties extensionattribute4 | 
    Where-Object{$time -ge $_.extensionattribute4}

由于我们需要使用该属性,因此需要确保在 -Properties 列表中返回该属性.

Since we need to work with that attribute we need to be sure it is returned in the -Properties list.