Intro to Powershell, Part 2 - Types

In the previous installment, I discussed 3 basic commands that help you navigate around Powershell. This post is focused on the data Powershell makes available through commands, and how you can manipulate it. Types are where Powershell starts to look more like a scripting language than just a shell. First a few basics. Powershell is object-oriented. This deviates from most shells like Cmd or Bash, where it is really string based. »

Intro to Powershell, Part 1 - Commands

Today, I decided that I didn’t like most of the Powershell intro articles and books out there. They focus a lot on semantics, details, language structure, and really complex use cases. But those are all orthogonal concerns. What really matters is what you can do with Powershell right now and what you need as a foundation. This is my attempt at creating a simple, light weight introduction to Powershell so that you can get started in minutes, not days. »

Using Powershell for MD5 Checksums

The older I get, the more paranoid I get about things I download. Today I downloaded a freeware program from a 3rd party download site, since the publisher doesn’t actually allow downloading from their site. All they give is an MD5 checksum. Well, I decided to write a quick Powershell script to do the checksum for me. (Got some pointers from another blog writing a cmd-let to do the same thing) param ( $file ) $algo = [System.Security.Cryptography.HashAlgorithm]::Create("MD5") $stream = New-Object System.IO.FileStream($file, [System.IO.FileMode]::Open) $md5StringBuilder = New-Object System.Text.StringBuilder $algo.ComputeHash($stream) | % { [void] $md5StringBuilder.Append($_.ToString("x2")) } $md5StringBuilder.ToString() $stream.Dispose() I probably should add a try/catch for the stream disposal and file existence validation. »

Powershell? Yes

I have read over Scott Hanselman’s Tool List at least a dozen times. The first time I read it, I saw that Powershell was on his top 10. I knew a little about Powershell from Exchange 2007 but hadn’t taken any time to look at it. About a month ago, I had to write some server maintenance scripts. Things like deleting files older than X days, SQL Server maintenance, etc. These tasks were perfect for scripting, so I picked up a Powershell book and went to town. »

SQL Server 2005: Backup, Restore, and Orphaned Users

Backing up a SQL Server database and restoring it to another server is a common operation done for reporting, testing, or development. When restoring on a different machine, a common problem is the login principals don’t actually correlate to the restored database users. This is because they are linked by an SID. This SID isn’t the user name, its some hash value, probably a GUID. The problem is fully described in this article. »