Monday, May 31, 2010

Another Reason Why PowerShell Matters

I’ve just been reading an interesting blog article in Peeters Online about fixing a DCOM issue that affects some machines. The issue results in Error Log entries with DCOM Event 10005 – Service can not be started. At least one common cause of this is disabling the Remote Storage Manager. The solution involved some manual registry editing and that is something I really do NOT like doing on production servers. 

In PeetersOnline, the author presents a nice PowerShell script to fix the issue. The script opens the remote registry, and does the necessary fixes. The script is parameterised therefore suited to larger organisations but more importantly, seems to handle the key error situations (keys not being found, not able to connect to the remote registry). You could go further, and create a trouble-shooter using the Windows SDK to enable remote admins to do the job even more simply (and perhaps both avoiding doing it where not needed and ensuring it’s done properly where it is).

This script shows how PowerShell can be used both to automate a solution and at the same time ensuring good documentation on what the fix is. The script , but also provides a measure of security from the admin that can’t type well! The reliable repetition of accurate instructions is a key to improving availability. It is things like this that make PowerShell so important.

Technorati Tags:

Sunday, May 30, 2010

Awesome script

I just saw a neat post over on twitter regarding Beyond Export-Csv: Export-Xls 

This is an awesome script, and one I've put into my profile already!! It might be a good addition to PowerShell Community Extensions.

Sunday, May 23, 2010

PowerShell Admin Module

I’ve been playing a bit with a Codeplex project called PowerShell Admin Modules (PSAM). Developed by Richard Siddaway, PSAM is intended to supply a number of PowerShell modules for use by IT Pros. The first of these modules contains 6 functions that work with shares, as follows:

  • Get-Share
  • Get-ShareAccessMask
  • Get-ShareSecurity
  • New-Share
  • Remove-Share

Using this module is easy. First download the zip file from Codeplex and expand the contents into your modules folder. Then import the module using Import-Module. It looks like this:

PSH [C:\foo]: import-module PAMSHARES
PSH [C:\foo]: get-command * -module pamshares

CommandType     Name                                                Definition
-----------     ----                                                ----------
Function        Get-Share                                           ...
Function        Get-ShareAccessMask                                 ...
Function        Get-ShareSecurity                                   ...
Function        New-Share                                           ...
Function        Remove-Share                                        ...
Function        Set-Share                                           ...

PSH [C:\foo]: new-share c:\foo foo2
Share foo2 was created
PSH [C:\foo]: get-share foo2

Name                                    Path                                    Description
----                                    ----                                    -----------
foo2                                    c:\foo

PSH [C:\foo]: remove-share foo2


The module works well enough although get-share does not seem to support wildcards and the order of the parameters in New-Share is different from that of Net Share (for those of us who even remember Net Share!). I’ve posted a fix to the wildcard issue on CodePlex. For the other issue, one could just change the order of the parameters in New Share. This is the joy of open source proejcts like this – you can fix ‘bugs’ and make your own changes as you see fit.

Friday, May 14, 2010

PowerShell Community Extensions (PSCX) 2.0 Released

A new version of the PowerShell Community Extensions (PSCX), version 2.0, has been released and is available from Codeplex (http://pscx.codeplex.com/releases/45101/download/121340). This free set of PowerShell extensions provides a number of very useful enhancements, particularly new/added cmdlets.

The main purpose behind the 2.0 release was to migrate the code from being a snap-in to being a module. As it’s a module, deployment is really simple – just Xcopy the files into your module folder and use Import-Module to load the module (typically you just put the Import-Module into my $profile). You can of course, put the module somewhere else and specify the full path using the Import-Module cmdlet.

PSCX also includes some NEW cmdlets, including:

  • ConvertTo-Metric
  • Get-AlternateDataStream
  • Test-AlternateDataStream
  • Remove-AlternateDataStream
  • Unblock-File
  • Get-LoremIpsum (lorem)
  • Get-TypeName (gtn)
  • Get-Uptime
  • Get-FileTail (tail)

This package is a great set of very useful extensions. Being module based, deployment is much simplified. I commend this release to all PowerShell users!

Wednesday, May 05, 2010

MSDN Webcast: Powershell for Data Professionals Tomorrow (May 5th)

I just got news of an interesting SQL PowerShell web cast coming up tomorrow. In the webcase, Microsoft SQL Server guru Aaron Nelson is going to look at how you perform everyday database administrator tasks using POwerShell. He’ll cover backing up user databases, scripting table objects, and evaluating disk space usage. The idea is to demonstrate how PowerShell scripts can be used to automating SQL Server activities.

Sign up for the web cast here: MSDN Webcast: geekSpeak: Powershell for Data Professionals (Level 200). I’ll try to post details of the recordings after the event for those that can’t make it.

Technorati Tags: ,,