0

I'm building a script that makes 4 lists: AD users and computers who've been inactive for x days and users and computers who've been disabled for x days.

I already have such a script in vbscript but currently I'm rewriting it in Powershell and my results are different regarding "users and computers who've been disabled for x days".

I've used Search-ADAccount to find my results. It turns out that the returned values for LastModifiedDate are not correct. (which I use to check the "days disabled"-value). I've built a command with Get-ADUser which should returns the same dataset. That resultset does have the correct values for LastModifiedDate.

So I'll rewrite my script to use Get-ADUser and Get-ADComputer and not search-adaccount. But I'd like to know why it's different. It also doesn't matter if I run it on my workstation or on a server. (so it's not a client-issue).

1 Answer 1

0

Search-ADAccount needs a time parameter to be specified. Check here for details on searching for inactive accounts: http://technet.microsoft.com/en-us/library/ee617247.aspx

I've not used this cmdlet but I have used Get-ADUser with pretty good success.

Anyway, I'd imagine the -timedate or -timespan parameters would also need to be specified for searching on LastModifiedDate properties. I don't know for sure. Just a thought.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the comment. I did use the timespan parameter, but my problem was that the results returned aren't correct. In the meantime I managed to do with get-aduser.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.