• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Disabling AD objects with Powershell

btcomm22

Member
I have run into a bit of a snag, I want to disable/delete computer objects depending on how long it has been since they were last logged onto. It seems to work fine, I got my list of computer objects through the following code.

$systemListdisable = Get-ADComputer -SearchBase $srcOU -Filter {LastLogonTimeStamp -lt $date -and Description -ne "Exempt"} -Properties LastLogonTimeStamp

Basically I want it to include the object unless the Description on that object is "Exempt". The issue seems to be that the code "-and Description -ne "Exempt"" seems to also exclude objects that have no description also. I don't see how this code would do that, anyone have any issue similiar to this?

If I use the code below it will disable the object even if the description is blank.

$systemListdisable = Get-ADComputer -SearchBase $srcOU -Filter {LastLogonTimeStamp -lt $date} -Properties LastLogonTimeStamp
 
Back
Top