comparing vbscript and powershell

I decided a good way to play with powershell was to convert one of my old wmi vbscripts to the new shell. I wrote this particular script a couple years ago to delete cached peap(802.1x) creds out of the registry stored under “HKCU\software\microsoft\EAPOL\UserEAPInfo”. There can be any number of subkeys, so I had to recursively delete the contents of each key. Vbscript and wmi make this possible, but not a very pleasent experience. You can take a look at the code here

Now, in the powershell world you can treat the registry almost like the filesystem. This should make my life much more pleasent. Let’s find out.

$key = “HKCU\software\microsoft\eapol\usereapinfo”
cd Registry::$key
rm * -recurse -whatif

That’s all there is to it. The -whatif will tell you what the action would have done without actually executing the command. A very handy feature that I will definitely be taking advantage of. You could even do it as a oneliner with wildcard expansion…

cd Registry::HKCU\soft*\micro*\eap*\usere*; rm * -recurse

Wow. Now that’s nice.