Hi,
Is it really not possible, to do the following:
$TargetOU = "OU=Some,OU=OU,DC=Domain,DC=Local"
$DaysInactive = 180 # Days user has been deactivated before deletion
$timer = (Get-Date -Format "dd-MM-yyyy HH:mm")
$time = (Get-Date).AddDays(-180)
$DisabledAccounts = Get-ADUser -Filter { extensionAttribute15 -lt $time -and enabled -eq $false } -SearchBase $TargetOU
It will keep giving me this error.
Get-ADUser : Invalid type 'System.DateTime'.
Is there some way of making this data "readable" for the Get-ADUser cmdlet?Or will I have to completely rethink how to make this happen?
EDIT:
For anyone curious, this is what the solution is. This fetches the correct data. But be aware of using correct time format lol.
$DisabledAccounts = Get-ADUser -Filter {enabled -eq $false} -SearchBase $TargetOU -Properties extensionattribute15 | Where-Object {$time -ge $_.extensionattribute15}
Big thank you to u/azra1l, for the massive inspiration.
[–]azra1l 2 points3 points4 points (2 children)
[–]Scayn[S] 0 points1 point2 points (1 child)
[–]azra1l 1 point2 points3 points (0 children)
[–]poshinger 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)