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.

No comments: