Monthly Archives: September 2011

Delete User Profile

The other day I was in need of deleting over 100 profiles and found the built-in Windows tool to be inefficient for this task.  I came across some PowerShell code that was a life saver.  Using the code below I was able to write a script and automate the task.

Finding the User Profile:

$username = "user"

$computername = “computer”

$userProfile = Get-WmiObject -computer $computername win32_userprofile -filter “LocalPath like `’%\\$username`'”

Note: Edit $computername variable with the name of the computer with the profile on it.  Yes this can be done remotely.  Also edit the $username variable with the user you are looking for.

Verify Correct User Profile:

$userProfile

Note: You do not want to delete the wrong user profile.  Always double check.

Deleting the User Profile:

$userProfile | Remove-WmiObject

Note: This code is only for users that have been properly logged off and their registry hive has been unloaded.  If you see an error, one of those two reasons may be the problem.   Restarting before you delete is one way to make sure the registry hive is unloaded.



Recovering AD Users and Computers

Periodically I find myself needing to recover a user or computer that has been deleted from Active Directory, and every time I go Googling.  When I finally find the solution, I have to sit back and ask myself, why do I not document this.  So here it is, my documentation on recovering a deleted user or computer.  Enjoy.

Requirements:

  • Windows Server 2008 or 2008 R2
  • Active Directory 2008 or 2008 R2
  • Active Directory Module for Windows PowerShell (obtained through the Add Features in the Server Manager tool on Domain Controller)

Process:

  • Open Active Directory Module for Windows Powershell as administrator.
  • Now utilize the Get-ADObject command.

Searching for Users or Computers:

Search for a particular user

Get-ADObject -Filter {Deleted -eq $True -and Name -like "username" -and ObjectClass -eq "User"} -IncludeDeletedObjects

Search for a particular computer

Get-ADObject -Filter {Deleted -eq $True -and Name -like "computername" -and ObjectClass -eq "Computer"} -IncludeDeletedObjects

Note: Asterisks can used in the filter.  “*username*” and your filter can be as simple or as complex as you need.  As long as you include the -IncludeDeletedObjects parameter you should be good to go.

Restoring a User or Computer:

Once you use one of the above commands to locate the user or computer you want to restore, then pipe Restore-ADObject to the end of the statement.  Examples below.  Please make sure your results in your search are the only objects you want restored.

Restore a particular user

Get-ADObject -Filter {Deleted -eq $True -and Name -like "username" -and ObjectClass -eq "User"} -IncludeDeletedObjects | Restore-ADObject

Restore a particular computer

Get-ADObject -Filter {Deleted -eq $True -and Name -like "computername" -and ObjectClass -eq "Computer"} -IncludeDeletedObjects | Restore-ADObject

Restoring other AD Objects:

This method can also be used to restore other deleted objects in AD.  In order to do that you will need to edit the filter to return the needed object.


Obtaining a Bag of Crap

Bag of Crap

What is a Bag of Crap you may ask.  Before I tell you I want to tell you a little about Woot.com.  Woot is a one day deal sale website.  They sell any random assortment of items through out the year including items such as computer mice, garage door openers, computers, or even 42″ TVs.  On rare occasions this website will sell a Bag of Crap.  A Bag of Crap costs $3 plus $5 shipping, so $8 total.  It consist of and is not limited to three items totalling at least $8 worth of stuff.  The items are random and can possibly be worth much more than $8.  Some even claim to have gotten a TV.  My best snag so far has been an electronic Batman helicopter that actually flies.  Also be warned some things have already been used and may not actually work.  Here is a link to the Bag of Crap commandments.  Scroll to the bottom where it says “The Holy Crap Commandments”.  Bag of Crap Commandments

Obtaining a Bag of Crap

Near the end of last year is when I first found out about the Bag of Crap and made it my mission to obtain one.  After much patience and lucky timing I have obtained 6 Bags of Crap this year and I have figured out some tricks to help me do so.  I thought I would be nice and post these tricks to help others.  Please be aware that there are no guarantees, and with Woot there are always surprises.  Plus, most of the time their servers crash.  These tricks should hopefully increase your chances of getting a Bag of Crap.  One important thing to note it no matter how many tricks you learn getting a Bag of Crap is all about luck, chance, and persistence.

Tricks:

Be aware of Woots time.  Woot is based out of Texas so their time is based on Central Standard Time (GMT -6) or Central Daylight Time (GMT -5) depending on the time of the year.

Make sure you are logged in and your credit card security code is memorized.

Dates

Important dates to be logged in and at Woot at 12:00AM

  • 04/01 – April Fools Day (Be prepare for trickery)
  • 07/12 – Woot’s Birthday
  • 12/25 – Christmas

Woot Off

Woot Offs are where I have had the most luck.  A Woot Off is a day where items are put up for sale until they sell out, then a new item is put up for sale.  Woot Offs range between 1 to 3 days but most last only 2 days.  The majority of Woot Offs will have a Bag of Crap for sale at some point.  Usually they are sold between 1:00PM and 5:00PM on the last day of the Woot Off.

Woot Games

From time to time, April Fools Day, their birthday, or even Christmas there are special Woot games to earn a Bag of Crap.  Most of these games have tricks to them so carefully read the Woot page before beginning.  One example of a Woot game is Crapshoot from last April Fools.  You had to beat the level that the current Bag of Crap was labeled with.  So if the Bag of Crap was Bag of Crap level 3 you had to play Crapshoot and beat level 3 to be able to purchase a Bag of Crap.  You can still play Crapshoot at http://www.woot.com/Crapshoot but no Bag of Crap left sorry.

Bag of Crap up for Sale

Once the Bag of Crap is up for sale start clicking “I Want One”.  Using multiple tabs and computers is always helpful.

Good luck and feel free to share your tricks, and successes.