Monday, March 30, 2009 10:03 PM Central Time
Posted by Justin

Back in December I wrote a posting on “Discovering Stale Computer Accounts with PowerShell”.  Today I received an email from one of my readers (Thanks Matt for writing!) trying to adjust the script to query for stale user accounts.  The script that I created in the previous entry is a good starting point, but requires some modifications to work properly for user accounts.

The biggest change in the script is that the DirectorySearcher filter has to be modified to look for user accounts.  Simply changing  the filter to “user” from “computer” doesn’t quite work as for some reason ADSI will retrieve both the user accounts as well as the computer accounts.  We can further limit the search by adding the ObjectCategory in addition to the ObjectClass.

This particular example will query on the last password change date.

function Get-StaleUserAccounts
{   
    # Use Directory Services object to attach to the domain
    $searcher = new-object DirectoryServices.DirectorySearcher([ADSI]"")
    
    # Filter down to user accounts
    #when you query for objectClass=User, you will not only get user accounts but also computer accounts. 
    #To limit the search to true user accounts, you would have to also include the objectCategory
    $searcher.filter = "(&(objectCategory=person)(objectClass=User))"
    
    # Cache the results
    $searcher.CacheResults = $true
    $searcher.SearchScope = “Subtree”
    $searcher.PageSize = 1000
    
    # Find anything you can that matches the definition of being a user object
    $accounts = $searcher.FindAll()
    
    # Check to make sure we found some accounts
    if($accounts.Count -gt 0)
    {             
        foreach($account in $accounts)
        {
            $LastPassChange = [datetime]::FromFileTimeUTC($account.Properties["pwdlastset"][0]);    
        
            # Determine the timespan between the two dates
            $datediff = new-TimeSpan $LastPassChange $(Get-Date);
            
            # Create an output object for table formatting
            $obj = new-Object PSObject;
            
            # Add member properties with their name and value pair
            $obj | Add-Member NoteProperty AccountName($account.Properties["name"][0]);
            $obj | Add-Member NoteProperty LastPasswordChange($LastPassChange);
            $obj | Add-Member NoteProperty DaysSinceChange($datediff.Days);
            
            # Write the output to the screen
            Write-Output $obj;
        }
    }
}
 
# Get user accounts where a password change hasn't occurred in 60 days or more
# If nothing outputted, then there are no accounts that meet that criteria
Get-StaleUserAccounts |Where-Object {$_.DaysSinceChange -gt 60}
Monday, March 2, 2009 9:55 PM Central Time
Posted by Justin
[caption id="attachment_209" align="alignleft" width="168" caption="Acer 10.1" Netbook"]Acer 19.1" Netbook[/caption] Picked this up last weekend.  Netbooks are all the rage right now.  A simple, compact laptop that provides enough power and performance to do email, offer Internet access, and use Office apps.  Battery life is between 4-8 hours depending upon what you do.  The Acer that I purchased is suppose to get about 7-8 hours of power.  The first batch apparently is shipping with the larger (longer lasting) battery, while later productions will ship with a smaller battery capable of 4-5 hours; which is still great. I loaded mine with Windows 7, Office 2007, and a few other apps that I use regularly.  This is the perfect device for travelers who regularly have to present (VGA output), like to take notes in a meeting or lecture, or just need quick access to email.  It weighs under 3 lbs., so you can't ask for much more.  It ships with 1GB RAM, but for $20 you can swap out the 1GB chip for 2GB. So far, I'm very impressed with it.  I did my research on these, which was a very frustrating process.  It is really hard to find full specs on a lot of these units, specifically information about upgradability of RAM and hard drive.  Needless to say, I saw a few people out in Redmond running with the Acer (both 8" and 10" screens), and were very happy with them.  The Acer is available through Amazon, CostCo, and MicroCenter.
Monday, March 2, 2009 7:18 PM Central Time
Posted by Justin
I was looking for a creative way to be able to share my USB hard drive that I had formatted for the Mac with my PC.  HFS Explorer, worked fine, but required me to extract files instead of being able to expose the volume as a drive letter.  I decided I would search for something that would allow my Mac to not only read (which OS X does by default), but also write to an NTFS partition.  I was going to reformat my USB hard drive as NTFS since I now primarily use it with my PCs. My search turned up an app called MacFUSE.  MacFUSE, as the website indicated, "implements a mechanism that makes it possible to implement a fully functional file system in a user-space program on Mac OS X (10.4 and above). It provides multiple APIs, one of which is a superset of the FUSE (File-system in USEr space) API that originated on Linux. Therefore, many existing FUSE file systems become readily usable on Mac OS X." Next, my search turned up NTFS-3G, a driver that sits on top of MacFUSE and enables full read and write capabilities of NTFS under the Mac OS.  I installed MacFUSE, and then NTFS-3G.  After a reboot, I was on my way to copying files from the Mac to a USB hard drive, now formatted as NTFS.  Well, kinda. What I figured out is that the NTFS-3G driver seemed to cause a lot of problems with my Mac OS.  Any time file access was taking place, whether it be on an HFS or NTFS file system, things seemed to "konk" out after a while.  For example, I was copying a few ISOs over, and half way through the copy would error out, but it seem to hang the entire operating system.  I tried several different files, large and smaller, with the same result. I quickly removed MacFUSE and NTFS-3G and my problems relating to file system operations seemed to go away.  Not sure what was happening there.  For now I have decided to copy files through my virtual machine to the external drive.  It adds a layer of abstraction, and seems to hinder the performance somewhat, but the copy operations do finish successfully. Have you used MacFUSE or NTFS-3G and had a different experience?