Monthly Archives: May 2012

powershell and captured printers

Peter wanted an  inventory of printers attached to a print server.  Sure, i said, and started to look for WMI objects of interest. Turned out to be ridiculously easy.  From two posts Chris Towles (provided by James Douglas) and MichaelStevelmans, i got … Continue reading

Posted in Uncategorized

write-verbose

Don Jones clearly thinks that write-host is evil (and you are killing pupplies…) but swapping out write-host and write-output is not a great victory.  I admit i get a thrill out of seeing “starting program”, “starting main” and “finished” while … Continue reading

Posted in Uncategorized

Select distinct and order by

Being your typical lazy programmer, i needed to create a LMS script file for management.  It was to be two columns, pipe delimited, with a header.  No problem.  Do the query, copy the two columns, paste into excel, write a … Continue reading

Posted in Uncategorized

http://mjolinor.wordpress.com/2012/01/29/powershell-hash-tables-as-accumulators/

I use hashtables ALOT – especially to generate counts or lists of values associated with a unique key.

Something like 

if($hash.containskey($mykey))
{
$hash.Set_Item($mykey, $hash[$mykey] + 1)
}
else
{
$hash.add($mykey,1))
} # end if/else

$hash will (shortly) contain a list of keys and their count.  You can put other things in as well.

This post by mjolinor is truly great for that (and there is more)

Continue reading

Link | Posted on by