Cleanup Inactive AD Accounts w/ PowerShell Pt 3: Splatting, Where-Object, Move-ADObject

preview_player
Показать описание
In the previous two videos, I made a simple script that finds and disables all computers in an OU that have not had any users logon to them in the past 45 days and updated the AD description to include the disabled date.
In this video, I'm going to further expand the script by moving the disabled computers to another OU for inactive computers and then removing the ones from that Inactive OU that haven't had any users logon in the past 90 days.
In the process, I'll show you how to use Splatting for easier parameter input, the Where-Object command to filter output, and a couple other basic commands to manage Active Directory objects.

Chapters:
0:00 Intro & Script Demo
0:43 Script Changes
1:12 Splatting
2:52 Remove-ADComputer
3:56 Where-Object
5:20 Move-ADObject
5:44 Script Demo & Conclusion

Write-Up:
Рекомендации по теме
Комментарии
Автор

Love you videos already. Is there a way to filter out Admin accounts in this search?

joshua
Автор

Good video. It's short and to the point. I do have a couple suggestions.

Since the AD Recycle Bin is a feature that needs to be enabled, I would suggest including a statement about that. Apologies if you've covered that in a previous part. Someone could execute the code assuming they could restore and find themselves without the capability.

Additionally, the attribute Protect from Accidental Deletion could prevent a computer object from being moved or deleted. And if the computer happens to have Microsoft Message Queue (MSMQ) installed, the configuration is stored in a leaf object on the computer object. This would also percent it from being deleted as you would need to remove the MSMQ leaf first.

I realize the latter topic is fairly advanced, but it's a possibility that an AD admin could run into.

Keep up the good work. I think your approach to breaking down a script into small videos like these can help many.

davecarroll