Along the same lines of the question about autohotkey scripts: http://superuser.com/questions/7271/, just now it's about Powershell.
Any usefull, handy or powefull scripts. Please describe what they do. Feel free to include scripts that don't have anything to do with server jobs or sysadmin tasks.
For example:
This command will recursively move your *.jpg images into the current directory, and add the originally containing directory name as a prefix for the image file.
(ls -r -include *.jpg) | % { mv -literal $_ $_.Name.Insert(0, [String]::Format("{0} - ", $_.Directory.Name))}
Or something you can run on text documents:
$badString = "This is not the way it should be."
$badString #for debug only
while ($badString.Contains(" ")){
$badString = $badString -replace " "," "
}
$badString #tada
Because Powershell is the future.