first_page

PowerShell Stop-Motion Programming

This line is cool:Rename-Item $f.FullName $new_name The line above reminds me that variables just ‘hang out’ during a PowerShell session. Above we have variables $f and $new_name, where $f is a FileInfo object (obtained by Get-Item) and $new_name is a System.String. This latter variable is set like this:$new_name = $f.Name.Replace("PowerScripting_Episode_7","PSPodcast-007") Windows PowershellAgain, these variables just ‘hanging’ can be used to great effect. It allows me to ‘meditate’ on one line of .NET-like code. This is something more than the old Immediate Window from the days of VBA. This is more engaging (and relaxing) than stepping through a debugger.

In fact, the store of session variables is treated like a drive—yes, a PSDrive! Try this line in your copy of PowerShell and see what happens: dir variable: (colon included).

PowerShell teaches .NET programmers, who are traditionally writing code for a Web server or data access, to write code directly against the Windows environment—in relaxing slow motion!

rasx()