I’m running an inventory of computer objects in several child OU’s. I want to break the computers in each OU down by OS type and record the last time any computer of that OS type logged in within each OU. I’m using the “lastlogondate” attribute of the compauter, and I get a result. The problem is I’m getting the data back in the format of “@{lastlogondate=3/27/2017}”. How do I remove the “@{lastlogondate=}” part and leave just the date. Here’s the relevant code:
I’m using version 5.1 and I can’t reproduce the formatting error so maybe there is a version issue.
That said I came up with an possible alternate way to get you to the same end result.
In the example below, I’ve derived the OU from the Distinguished name using Select-Object and RegEx. For quicker debugging I’ve piped it out to gridview since I find it does a good job of giving excel like results. You can change this to Export-CSV if you want.
If you have a large AD environment (more than 5000 computer objects), you may want to tweak the Get-ADComputer filter from * to something with less results.
I’m not sure what to tell you, Matt. I tried it the first time and the results were as I explained. I waited a while and tried it again and it works beautifully. Not sure what changed or why but obviously something did.