O R G A N I C / F E R T I L I Z E R: 09.09

Sep 24, 2009

list active directory subnets with powershell

Windows PowerShell

sometimes it’s fun to do things the long way (not) and then do the equivalent in a shortcut fashion.

these are the steps i used to retrieve subnets from active directory.


first of all, let’s grab the forest.

$myForest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()


now, we can get the list of sites names.

$myForest.Sites | Select-Object name


if we see a site name that we like, we can retrieve just that site name and the subnets associated with it.

$myForest.Sites | Where-Object { $_.Name -eq 'myCity' } | Select-Object Subnets


well, that’s probably not what you wanted unless you have such few subnets you can see the whole thing.  let’s pass that through the ExpandProperty feature of select-object.

$myForest.Sites | Where-Object { $_.Name -eq 'myCity' } | Select-Object -ExpandProperty Subnets


that’s better!

Sep 16, 2009

using powershell select-string creatively…

this came up yesterday.  i thought it was cool enough to blog.  i’m sure this is pretty elementary for most of you.


i was trying to find a way to search a list of files for content and pull back some attributes along with the search.  the problem is once you pass objects from get-childitems through select-string, the type changes.


looking at the object type

let’s look at the type before we send it through select-string:

PS C:\data\temp> ls | gm -MemberType property

   TypeName: System.IO.FileInfo

Name              MemberType Definition
----              ---------- ----------
Attributes        Property   System.IO.FileAttributes Attributes {get;set;}
CreationTime      Property   System.DateTime CreationTime {get;set;}
CreationTimeUtc   Property   System.DateTime CreationTimeUtc {get;set;}
Directory         Property   System.IO.DirectoryInfo Directory {get;}
DirectoryName     Property   System.String DirectoryName {get;}
Exists            Property   System.Boolean Exists {get;}
Extension         Property   System.String Extension {get;}
FullName          Property   System.String FullName {get;}
IsReadOnly        Property   System.Boolean IsReadOnly {get;set;}
LastAccessTime    Property   System.DateTime LastAccessTime {get;set;}
LastAccessTimeUtc Property   System.DateTime LastAccessTimeUtc {get;set;}
LastWriteTime     Property   System.DateTime LastWriteTime {get;set;}
LastWriteTimeUtc  Property   System.DateTime LastWriteTimeUtc {get;set;}
Length            Property   System.Int64 Length {get;}
Name              Property   System.String Name {get;}


now after select-string:

PS C:\data\temp> ls | Select-String marcus | gm -MemberType property

   TypeName: Microsoft.PowerShell.Commands.MatchInfo

Name       MemberType Definition
----       ---------- ----------
Context    Property   Microsoft.PowerShell.Commands.MatchInfoContext Context {get;set;}
Filename   Property   System.String Filename {get;}
IgnoreCase Property   System.Boolean IgnoreCase {get;set;}
Line       Property   System.String Line {get;set;}
LineNumber Property   System.Int32 LineNumber {get;set;}
Matches    Property   System.Text.RegularExpressions.Match[] Matches {get;set;}
Path       Property   System.String Path {get;set;}
Pattern    Property   System.String Pattern {get;set;}


retrieving the original attributes

as you can see, after sending it through select-string, it converts the type from FileInfo to MatchInfo.  as long as i only care about the properties i can use from matchinfo, that’s not really a problem.  as noted here:

PS C:\data\temp> ls | Select-String marcus | ft filename, line -auto

Filename        Line
--------        ----
machinelist.txt MARCUS


that becomes a problem since the original attributes aren’t maintained.  for example, let’s say i want to pull back the creation time of the file.  this illustrates the problem:

PS C:\data\temp> ls | Select-String marcus | ft filename, line, {$_.creationtime} -auto

Filename        Line   $_.creationtime
--------        ----   ---------------
machinelist.txt MARCUS


if we embed a command, we can retrieve the item again and then pull back the property of it.

PS C:\data\temp> ls | Select-String marcus | ft filename, line, {(ls $_.filename).creationtime} -auto

Filename        Line   (ls $_.filename).creationtime
--------        ----   -----------------------------
machinelist.txt MARCUS 4/16/2009 1:45:10 PM


shout out

lots of thanks to shay levy and hal rottenberg for their incredibly rich powershell knowledge.

Sep 10, 2009

how to identify the smsexec thread when processor utilization is high

there’s no secret formula to this.  you’ll just have to roll up your sleeves and do it.  apparently, this used to be in some old article Q234508 which has been removed for whatever reason since this works with sms 2.0, sms 2003, and configmgr (sccm) 2007.


identifying the instance

on your troubled server, use these steps to get perfmon to show you where the problem is occurring:

  1. fire up perfmon (obviously).
  2. add thread object with the following counters:
    • % processor time
    • id thread
  3. for instances, choose all the instances that begin with smsexec.

could be quite a bit.  i had close to 90.

if you think it’ll help, you can try the report view (ctrl+r) to isolate the thread causing the problems.  otherwise, you can enable highlighting (ctrl+h) and with zen like patience, move through all of the smsexec threads until you see the thread that’s eating up % processor time.  sometimes it’s easier watching it in histogram view, then double-clicking the line that’s bouncing around like an ice cream charged 4 year old.

once you find it, write down the instance number.  (i don’t trust you to remember it).  don’t close out perfmon yet.


isolating the thread

once you’ve identified the instance, these steps will locate the thread value.

  1. in perfmon, scroll through your counter list until you’re in the id thread list. 
  2. find the corresponding instance number that you wrote down.
  3. highlight the instance and note the values in last, average, minimum, and maximum.  they should all be identical.  write this down, too.
  4. convert the value to hex using calc.

in my case, the value is 100980 which translates to 18A74.  go to your sms\logs directory and use any assortment of find that you prefer using the hex value of the thread as your search criteria.  why, here’s a good example, right HERE of how to do it. :)

your results should paint a nice picture for you.


additional details

you can get the full article HERE if you need more.

looking for a new IM client? try digsby and never go back! (and switch to alpha mode, if you dare)

Digsby Mascot

alright, i admit i might be a little slow.  i wasn’t catching the hidden message behind the trend initially.  lately, people i communicate with pretty frequently had either mentioned switching to digsby or asking my opinion of it.  i guess it has to do with a few well-placed statements about trying out new features in digsby like global status updates and here most recently, the tighter facebook integration.


switch to digsby

the trend i didn’t realize was that people are in search of a new messenger client – and usually one that handles all of their social requirements.  i’ve been a long time fan of messengers that are capable of interacting with a variety of services.  gAIM was where i started (which has since evolved to pidgin).  (for my macbook pro, i use adium).  about a year ago, i switched over to digsby.  i haven’t gone back since.  it connects me to all my email services, facebook, linkedin, twitter, etc.

anyway, i’m posting this because friends i’ve recommended to use digsby give me responses like “wow, this is cool” or “$#%#^%?  why haven’t you told me about this before?”.  so here it is, i’m telling you about it.


getting digsby

before you run off to go install digsby, consider using the alpha version.  i’m only recommending this because the facebook integration in this version rocks.  the stream let’s you make updates in line – such as commenting, liking, posting, etc.  i’d show you a screen shot, but i don’t really think it’s a good idea to project the updates of my friends.  :)

anyway, if you’re looking for the digsby install files, you can get them here:

regular - http://www.digsby.com/download.php?os=win
alpha – http://update.digsby.com/install/digsby_setup_alpha.exe


running digsby alpha

one other thing, you can set digsby to update to alpha code.  if you’re already running digsby, here’s how to do it.  this used to be posted on their site, but i can’t seem to find it anymore:

  • go to the folder c:\program files\digsby
  • create a new file called "tag.yaml"
  • populate the contents of the file with this:

tag: alpha


(yes, include the –-- in the file).

  • save the file
  • log off digsby
  • log on to digsby, upgrade will start
  • log on again

Sep 3, 2009

dell server management pack suite v4.0 released

Dell computer

Image via Wikipedia

if somehow you haven’t heard yet, dell released their newest management pack – finally.  it looks as if it’s been rewritten because quite frankly, if you had the misfortune of loading the previous one, then you know what a piece of crap it was.

the early word is that you cannot upgrade to 4.0.  it’ll be a wipe and reload.  anyway, here’s the link and a few light details.


Feature highlights of this Dell Server Management Pack Suite v4.0 (A00) -Improvements in scalability and performance over the previous releases by including:

  • Server Scalable MP (for managing large enterprise environments)
  • Server Detailed MP (addon MP that provides detailed instance level monitoring)
  • Performance and Power monitoring and OpenManage 6.1 support for Dell Server MPs
  • DRAC and CMC MPs to monitor Dell Remote Access Controllers and Chassis Management Controllers
  • Override utility to enable Informational alerts for managed Dell Servers