header image

Archive for PSAM

PAM release February 2012

Posted by: | February 5, 2012 | No Comment |

I have added another module to the PowerShell Admin Modules – http://psam.codeplex.com/


Release 0.7 adds a PAMHostsFile module with the following members



A release notes document is also available which includes a listing of all modules and members together with a history of releases.

under: PowerShell original, PSAM

Just been checking the stats on the PowerShell Admin Modules – http://psam.codeplex.com/ – and this month its reached over 1000 downloads.

I have a couple of updates in the pipeline that should be available soon.

under: PSAM


Posted by: | June 3, 2011 | No Comment |

Many numbers in computing are based on powers of 2. I need to calculate some powers of 2 and realised that PowerShell doesn’t have  an operator for raising  a number  to a power.  In many languages ** or ^ supply this functionality.

In PowerShell we drop back to .NET and use the System.Math class (still think that should be Maths!)

[math]::Pow(2,2) raises 2 to the power 2 and gives us the answer of four.

1..30 | foreach {[math]::Pow(2,$_)}

prints out the first 30 powers of two

Just out of interest 1GB is 2 to the power 30

We can make this a bit prettier

1..30 | foreach {
"{0,3} {1,15}" -f $($_), $([math]::Pow(2,$_))

Check the values for 1kb, 1mb and 1gb which are



I’ll convert this to a function and add it to the PAM maths module.

under: PowerShellV2, PSAM

New PAM version

Posted by: | May 22, 2011 | No Comment |

I’ve added the 0.6 release of the PowerShell Admin Modules to codeplex – http://psam.codeplex.com/

This release adds two modules

PAMADSNAPSHOT – functions for work with AD snapshots in Windows 2008 & 2008 R2

PAMLOAD – loads all of the PAM modules in one command

Import-Module PAMLOAD –Force


Further releases are planned during the year

under: Modules, PowerShellV2, PSAM

I had this comment left on my blog related to a tweet announcing the availability of the 0.5 version of PowerShell Admin Modules.

It raises a few interesting questions so I decided to reproduce it in full.  Thanks to Thomas for the questions.  I’ve put my answers in line in blue.

Some Questions about your code:


$bustype = DATA {

-> Keyword DATA:  what is this about? How do you call this Technique (So i can google for?) Are there more Keywords beside DATA?


The DATA keyword was introduced in PowerShell 2.  A DATA block is used to isolate text strings and other read-only data from the script code.  See Get-Help about_Data_Sections for more information. 

Other keywords include

Begin, Break, Catch, Continue, Data, Do, Dynamicparam, Else, Elseif, End, Exit, Filter, Finally, For, Foreach, From, Function, If, In, Param, Process, Return, Switch, Throw, Trap, Try, Until, While   

see get-help about_language_keywords for details


Think that you used: 
$bustype = DATA { … ConvertFrom-StringData
and not just a Hashtable like:

$bustype = @{
-1 = "Undefined"
0 = "Internal"
1 = "ISA"
2 = "EISA

is , because you just did not like to write the " "  or is ther another special reason why you did that? Think Both way’s produce a Hashtable as far as i saw it.


You are correct both ways will produce a hash table. I have been creating a lot of hash tables recently for WMI lookup functions. The values are in a table in the WMI documentation. It is less typing to create it the way I did

$bustype = DATA {
ConvertFrom-StringData -StringData @’
-1 = Undefined
0 = Internal
1 = ISA
2 = EISA

especially as I have a template for the code snippet to create the hash table. I also think it is easier to read. It has a bonus of introducing the Convertfrom-StringData cmdlet.

And My last question is, why you placed the $bustype assignment outside your function and not inside?


I put the $bustype assignment outside the function so that it is ( a ) available to other functions if needed. Its only created once when the module loads rather than every time the function runs.

Hope you find some minutes to answer my questions 😉


Actually Question Nr 4. about Modules in General came into my mind while writing this Email 🙂

You have Several Modules PAMSysInfo, PAMShares, …. I all would place in my modules Folder and then load with Import-Module..

I think i will also split up my scripts to multiple Modules.
What i like to do finally if possible is Following:

Having a Folder WindowsPowershell\Modules\PAM , and there are my "Sub"ModulesFolder  WindowsPowershell\Modules\PAM\PAMSysInfo,  WindowsPowershell\Modules\PAM\PAMShares, …

In the PAM folder itself i have a Preference File where i set the individual Submodules to load or not e.g.

ModulesToImport = @{                           
                PAMSysInfo     = $true         
                PAMShares   = $true
        PAMbla    = $false

So with a "Import-Module PAM" , all specified SubModules would be loaded. (Like said before, if this is Possible at all 😉 )
Maybe you like the idea as well for your PAM Modules.. I Think PSCX uses such a technique but i had just a very quick look to PSCX Structure..

I am looking at a overall module that will load the sub modules. It will either be editable or I’ll supply switches to only include specific modules (or maybe not include specific modules)

Hope this helped

under: PowerShellV2, PSAM

PAM 0.5

Posted by: | May 5, 2011 | No Comment |

Just released PowerShell Admin Modules (PAM) 0.5.  This adds the PAMStability module for working with stability and reliability metrics on Windows 7 and 2008 R2. The following 2 functions are available:


see http://psam.codeplex.com/

under: PowerShellV2, PSAM, Windows 7, Windows Server 2008 R2

PAM 0.4

Posted by: | November 20, 2010 | No Comment |

PowerShell Admin Modules 0.4 is now available.  This adds a PAMSysInfo module to the download that includes the following functions:


Get-SystemInfo is a top level function that calls the others for a full system information dump.  All functions take a computer name as their only parameter.

PAMSysInfo isn’t complete but there is enough to start making it useful

Download from http://psam.codeplex.com/


under: PowerShell and WMI, PowerShellV2, PSAM

PAM 0.3

Posted by: | November 14, 2010 | No Comment |

I’ve added another module to the PSAM project on codeplex.

Version 0.3 now has:

PAMShares – for working with shares
PAMMath – for working with binary and hex
PAMEnv – for working with environmental variables

The modules can be downloaded from http://psam.codeplex.com/


under: PowerShellV2, PSAM

PAM 0.2

Posted by: | June 1, 2010 | No Comment |

I’ve released the second module for the PowerShell Admin Modules tonight.  It is available from


This release includes two modules.

PAMShare (originally in PAM 0.1) contains the following functions:

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

Get-Share can now accept a wildcard  eg get-share t*

New-Share now has the share name as first parameter and path as the second.

Both of these changes are the result of feed back on the issues page

The second module is PAMMath.  It contains functions for working with binary and hex numbers

  • ConvertTo-Binary
  • ConvertTo-Decimal
  • ConvertTo-Hex
  • Get-BinaryAND
  • Get-BinaryDifference
  • Get-BinaryOR
  • Get-BinarySum
  • Get-BinaryXOR
  • Get-HexDifference
  • Get-HexSum
  • Test-Binary
  • Test-Hex

A help file is supplied with each module.


under: Modules, PowerShellV2, PSAM

Hex Subtraction

Posted by: | May 11, 2010 | No Comment |

Again this takes the pattern from the binary function and adapts it to work with hex

## this will always subtract value2 from value1
function Get-HexDifference {
## check valid hex numbers
    Test-Hex $inputvalue1
    Test-Hex $inputvalue2

    $diff = (ConvertTo-Decimal -inputvalue $inputvalue1 -hex) `
      (ConvertTo-Decimal -inputvalue $inputvalue2 -hex)

    if ($diff -lt 0){Throw "Hex subtraction produces negative number"}
    else {ConvertTo-Hex -inputvalue $diff}


As with the binary subtraction function we test to see if we’ve gone negative – if so reject the value.


That’s the end of the math module for now.  As soon as I’ve done the help files I’ll post it on codeplex.

under: Modules, PowerShellV2, PSAM

Older Posts »