Pro Tips: Bulk SID-to-name Conversion

Right now I’m working on deploying an RDS farm for roughly 150 users. Within the last six months I started using User Profile Disks instead of redirected folders and roaming profiles, and while it seems to work pretty well (and also avoids some of the weirdness that certain software has about local profiles), one major drawback is that the user profile disk VHDs are named based on that user’s SID, not their username. Makes total sense if you’re a server that can translate SIDs to something readable, but less so if you’re, you know, an actual person (thanks, Microsoft).

As we were nearing the cutover (this weekend), I wanted to send a list of users who had logged in (and, more importantly, users who had not logged in yet) to test their credentials, printers, etc, to the customer. While the PSGetsid utility from Sysinternals does a great job of resolving a SID to an account name, it only does that for one user, and I wanted a faster way to convert the 130-some SIDs to names. There are probably a dozen how-tos like this out there, including some that might work better, but this is the workaround that worked for me:

  1. First, get a list of those VHDs: open a command prompt, navigate to the share you’re keeping your VHDs in, and dump a dir of that directory to a text file.
  2. Open said text file in Excel (or the text editor of your choice) and strip out all the extraneous crap, so that you only have your SIDs. Save the file as a .csv.
  3. If it isn’t there already, copy the CSV to your domain controller and open the Active Directory PowerShell module (or load the AD cmdlets).
  4. Browse to your working directory and run the following command: gc | % { (get-aduser $_).name } > users.txt

That’s it! Now you’ve got yourself a list of usernames (display names, if we’re going to split hairs here) that you can check against an existing user list and use to send nagging emails to the users who haven’t tested the new environment out yet.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.