Powershell script to check the modification date of particualr computer accounts

I want to runa powershell script that chedks the modification date of computer accounts in a a particular ou. Ir xx.local\test OU. I would like this to output to a csv file. Furthermore, If possible I would like to only have the script flagg accoutns that have not been modifes in 48 hours.
ullmannericAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

FDiskWizardCommented:
This will give you a list of computers and last modified (WhenChanged attribute)

get-QADComputer -includedproperties whenchanged -SearchRoot 'my.local/ComputersOU' | select name,whenchanged | sort -descending whenchanged | export-csv -NoTypeInformation C:\MyDocs\computers.csv


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
FDiskWizardCommented:
PS: The 2 day timeframe can be done, and I have done something like that before on users, but I don't have time to provide that right now... Sorry.
0
ullmannericAuthor Commented:
When I run your script and change the seeting to apply . I keep getting cannot resolve directory object for the given identity.

xx.xxx.com/xx/xxOU
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

ullmannericAuthor Commented:
I fiqured out what was wrong now I will just need to fiqure out the two day thing
0
AwinishCommented:
OLDcmp from Joe Richard is the way to go.Download OLDCMP tool from Jo’e site & for cmd/usage see the below in the link.

http://joeware.net/freetools/tools/oldcmp/index.htm
0
FDiskWizardCommented:
Yeah, Joe has some good tools. Just be careful.. they could be deadly when modifying accounts.
If modifying do some testing on a small OU, or test OU.

One other note... and it shouldn't matter with LastModified.
But would matter for lastlogon...

If I recall, Joe's tools don't look at multiple DCs. If you just have one site, you may have better results. Lastlogon isn't normally replicated between DCs. So if a user is always logging into a DC in SITE2, Site1 will never see it... except maybe your PDC emulator.
When in full Windows 2003 Native/Functional there is a reg tweak to do replication of last logons.

0
FDiskWizardCommented:
Actually, the timeframe thing is easy with GET-QADComputer, it has an option to specify.

Get-QADComputer -service MYDC01 -searchRoot My.local/Computers   -LastChangedBefore 01/11/2011
0
AwinishCommented:
If DFL/FFL is at windows 2003 lastlogontimestamp attribute is replicated to all DC.
http://blogs.technet.com/b/askds/archive/2009/04/15/the-lastlogontimestamp-attribute-what-it-was-designed-for-and-how-it-works.aspx

Joe's tool check & compare this value, i have seen where dsquery & other tool gives conflicting report Joe's oldcmp is best.
0
FDiskWizardCommented:
An example from Get-ADComputer (activeDirectory module vs Quest...) which shows how to compare Date when there isn't something built-in
$d = [DateTime]::Today.AddDays(-90); Get-ADComputer -Filter 'PasswordLastSet -ge $d' -Properties PasswordLastSet | FT Name,PasswordLastSet

Should work fine with LastChanged attribute also.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.