PowerShell Special Characters

Posted by Drothism on Dec 12th, 2008

Here are some of the special characters that can be used in Windows PowerShell output:

  • `0 — Null
  • `a — Alert
  • `b — Backspace
  • `n — New line
  • `r — Carriage return
  • `t — Horizontal tab
  • `’ — Single quote
  • `” — Double quote

Some of these characters are intended for use only from the Windows PowerShell prompt. For example, the special character `a causes your computer to beep.


PowerShell Cheatsheet

Posted by Drothism on Dec 11th, 2008

PowerShell is Microsoft’s replacement for cmd.exe, the venerable NT command shell. It breaks new ground, introducing a powerful but completely new syntax. (If you don’t have it yet, download it here).

Revolutionary but different, users new to PowerShell will often find themselves lost - not being able to figure out how to do simple things that they’ve been doing in other shells for the last 20 years. This cheat sheet should help.

PowerShell’s native commands are all based on a verb-noun syntax, for example, “get-childitem”. Command names are often quite verbose, so there is an extensive list of default aliases that help with common commands. The table below will give the alias, where available, as well as the native PowerShell command.

Operation cmd PowerShell
Get a simple directory listing
alias: dir
Get a recursive directory listing
dir /s
get-childitem -recurse
alias: dir -r
Get a wide directory list
dir /w
dir | format-wide
alias: dir | fw
List built-in commands
alias: help
Copy a file
copy foo.txt bar.txt
copy-item foo.txt bar.txt
alias: copy foo.txt bar.txt
Move a file
move foo.txt c:\
move-item foo.txt d:\
alias: move foo.txt d:\
Rename a file
ren foo.txt bar.txt
rename-item foo.txt bar.txt
alias: ren foo.txt bar.txt
Batch rename
ren *.one *.two
dir *.pdf | rename
  -newname {$_.name -rep ".one",".two"}
Set the current directory to d:\
cd \
set-location d:\
alias: cd d:\
Clear the screen
alias: cls
List only directories
dir /ad
dir | where { $_.MshIsContainer }
Directory list, sorted by date
dir /od
dir | sort-object LastWriteTime
Directory list, sorted by date, descending order
dir /o-d
dir | sort-object LastWriteTime -desc
Show the current directory
alias: pwd
See a command’s help
dir /?
get-help get-command
or: get-help get-command -detailed
or: get-help get-command -full
or: dir -?
List environment variables
dir env:
Delete a file
del foo.txt
remove-item foo.txt
alias: del foo.txt
Find all *.txt files
dir /s *.txt
get-childitem -recurse -include *.txt
alias: dir -r -i *.txt
Find all *.txt files containing a particular string
findstr "foo" *.txt
dir *.txt | select-string "foo"
Show a list of services
net start
Start a service
net start MyService
start-service MyService
Stop a service
net stop MyService
stop-service MyService
Show network shares
net share
gwmi Win32_Share
Show a list of running processes
get-process alias: ps
Kill all notepad.exe processes
taskkill /im notepad.exe /f
ps notepad | kill

A few PowerShell commands that you can’t easily do with the standard Windows shell:

Operation PowerShell
Set the current directory to a UNC path
cd \\\\myserver\\\myshare
Get a list of event logs
get-eventlog -list
View entries in a particular event log
get-eventlog -newest 20 -logname System
Treat the registry like a filesystem
cd hkcu:
Recursive directory, grouped by extension
dir -r | group extension
Search for a file containing a string, recursive
dir -r | select-string "foo"
List the 10 processes using the most memory
ps | sort -p ws | select -last 10
Count the results of a directory listing
Count the results of a directory listing
$f = Get-Content "myfile.txt"
foreach ($item in $f)
{do stuff with $item}

There’s a lot to PowerShell, and this only scratches the surface. This guide is meant to help you get going with some everyday commands, but be sure to read some of these great PowerShell blogs, and the PowerShell Script Center for more in-depth tips. (And here’s a good reference on PowerShell syntax).


Opie for Obama

Posted by Drothism on Oct 24th, 2008

What would happen if Opie and Richie Cunningham had to ponder the 2008 election? Well now you can find out! Ron Howard dons a red wig to reapprise his roles as Opie and Richie, with special guests Andy Griffith and the Fonz.

Desperate times call for desperate measures!

See more Ron Howard videos at Funny or Die


30 second TIVO Ad Skipping

Posted by Drothism on Oct 20th, 2008

Looking for an even faster way to skip ads with your TIVO DVR? If you have a TIVO you probably already fast forward through most commercials, but find yourself talking or getting distracted by something and whizzing way past where you want to.

This quick hack requires nothing more than a few button presses on your TIVO remote control but will let you skip 30 seconds at a time with a single button press. 

Type in select-play-select-3-0-select to turn on the 30 second skip mode. You should hear a “ding-ding-ding” sound. That means you’ve made the change.

The skip button  will now advance your program 30 seconds with each press.

Don’t like it?

Type in select-play-select-3-0-select again, wait for your ding-ding-ding, and you’re back skipping to the end of the program.

Keep in mind that any automatic or manual restarts of the TIVO box will cause the 30 second skip hack to be lost and you will need to re-enter the select code again.

You aren’t likely to violate the TIVO warranty doing this, but, hey, don’t blame me if you start searching for even more select code hacks that do! Hint… more select codes can be found on the TIVO Community Forum.


Bone Rings from Biojewellery

Posted by Drothism on Oct 20th, 2008

I’m not sure if this is ultra-cool or just damn creepy. Scientists have taken research for rebuilding bones from fragments and figured out a way to grow bone cells on scaffolds to form ring shapes.

In the initial experiments rings were “grown” from a combination of bone cells from a couple and mixed with traditional precious metals.

Details on this intriguing project can be found on the Biojewellery site.


Bird is the Word!

Posted by Drothism on Oct 18th, 2008

Several months back I found the 1963 song “Surfin’ Bird” by The Trashmen and couldn’t resist turning it into my primary ringtone. Since that day I have enjoyed informing the world with each call I receive that Bird is the word.

Then just a few days ago I was happily informed by an bemused coworker that The Family Guy had a new episode that paid homage to this quirky and always amusing song. So for your viewing and listening pleasure, here is one of the funniest episodes ever of The Family Guy that reveals Peter’s obsession with “Surfin’ Bird”.


How to Record Hulu Shows for Offline Viewing

Posted by Drothism on Oct 15th, 2008

Web services like Hulu and Fancast are great for watching shows online. But what if you’re on a plane or otherwise disconnected from the Internet? Can’t you download shows for offline viewing on, say, a PC or iPod?

Unfortunately, Hulu, Fancast, and similar video-on-demand services don’t allow you to download their media. Instead, it’s streamed in real-time, with nothing actually getting stored on your PC.

And because the services rely on Flash software for playback, you need a desktop Web browser. Sorry, iPhone owners.

Of course, if you’re willing to put a little time, money, and effort into it, you can work around these limitations.

Applian Technologies Replay Media Catcher 3.0 can capture just about any streaming media and save it to your PC, where you can then watch it at your leisure (without an Internet connection) or convert it for viewing on a mobile device.

I used the $40 program to record the Jim Carrey classic Liar, Liar from Hulu. It was incredibly easy–press the record button, then start and pause the video–but it took a while to finish. That’s because Media Catcher records in real-time, so whatever the duration of the video, that’s how long it’ll take to capture.

The program stores files in a format called FLV, which can be viewed on your PC using an included player. However, if you want to convert them for, say, your iPod or iPhone, grab a copy of Videora iPod Converter. This free utility easily converts FLV files to an iPod-ready format. But it, too, takes time: just over an hour for a 90-minute movie.

Hey, I never said this was a quick, easy, or free solution. But if you want to stock up on episodes of Arrested Development, Firefly, and other gems to take on the road, this does the job.

Source: PCWorld.com


Skip Ads Easily With a Standard Cable Remote Control

Posted by Drothism on Oct 15th, 2008

Many Motorola-made DVRs that cable-TV providers supply are unable to skip ads by jumping ahead 30 seconds. But you can remap the remote control to add this feature. I got it working with a Comcast remote, and it will likely work with your cable company’s remote, too.

Comcast remote; click to view full-size image.Press the Cable button at the top of the remote. Hold the Setup button until the Cable button flashes twice. Enter 994 on the keypad. The Cable button will flash twice again. Push the Setup button once. Enter 00173. Finally, push the button that you want to use as the 30-second skip; I chose the A button since I don’t use it for anything else. The Cable button will flash twice.

To restore the original functionality to that key, follow the first steps described above, but after entering 994, push the remapped key twice. The Cable button will blink twice if your input has been accepted.


9 of The Oddest Experiments Ever

Posted by Drothism on Sep 30th, 2008

Reto Schneider has collected some of the most bizarre experiments conducted in the name of science for his book The Mad Science Book (reviewed here). Here he selects nine of his favourites.

read more | digg story


USB Popcorn Maker

Posted by Drothism on Sep 28th, 2008

So many USB hacks and so little time! This home brewed USB powered popcorn maker is one of the best inventions I have seen!