Sunday, January 30, 2011

Creating PSDrives for Modules

In my PowerShell training, I spend time examining modules and how you can use them to manage code and avoid profile bloat. In the (forgive the pun) modules on modules, I do lots of demos where being able to quickly set your location to the personal or system modules folder is useful. One simple way I demonstrate is to create PS drives pointing to the folders. I do this as follows:

# First, create variables pointing to each folder
$mod       = (ls env:psmodulepath).value.split(";")[0]
$sysmod    = (ls env:psmodulepath).value.split(";")[1]

# Now create PsDrives
New-PSDrive -name mod    -root $mod     –PsProvider FileSystem | out-null
New-PSdrive -name sysmod -root $sysmod  –PsProvider FileSystem | out-null

As you can see, I first create variables corresponding to the two built in Profile folders. The PsModulePath environment variable is set to a string holding the names of these folders, delimited by a semi-colon. Once I have the $mod and $sysmod variables, I can call New-PSDrive to create the drives. The last two PowerShell statements do return a value, so to to keep the output to a minimum, I just pipe the results to out-null (although I’ll quickly point out there are other ways to avoid the output!)

Friday, January 28, 2011

Powershell WebCast–Formatting in PowerShell

As I wrote earlier this week, on Wednesday night (well night in the UK!), I delivered PowerShell.Com’s first webcast. The webcast was a huge success – we had a total of 1350 people signed up to attend. At the peak we had just over 675 users watching (about par for the course in terms of attrition!). If you were amongst those who missed any or all of the web cast, or just want to re-see part of it, the web cast itself is posted to PowerShell.com (http://powershell.com/cs/media/p/8773.aspx). I’ve also posted my slides and demo code to my website – www.reskit.net/powershell/formatting.zip.

Enjoy!

Tuesday, January 25, 2011

Webcast: Formatting with PowerShell

Tomorrow, 26 January, I’ll be presenting a web cast of formatting with PowerShell. Those kind forks at Idera, sponsors of PowerShell.Com, have organised an on-line webcast where I’ll be looking at formatting with PowerShell. As of this afternoon, over 900 folks  have signed up for the event!! The webcast is live at 18:00 GMT (19:00CET). For the US folks, that works out to 13:00 EST and earlier further west.

The webcast examines how you format output using PowerShell. It’s aimed at a 250 technical level presentation. I first look at default formatting and using Format-Table and Format-List (and Format-Wide). I’l exmine .NET Composite formatting strings and PowerShell's -F operator – these enable you to format individual values into output strings. I’ll then move gears and look at using hash tables with Format-Table and Format-List to provide more precise control over the formatting of tables. I’ll also spend time answering your questions.

To find more about the webcast, and to sign up to attend, see: https://www2.gotomeeting.com/register/626513458. I hope to see you all there!