Custom Powershell Cmdlets and the mystery of System.Management.Automation.dll

Published on December 3, 2006

Just in case anyone else is banging their head against this brick wall.  I am playing around with trying to create my own Powershell cmdlets.  If you search around for samples on doing this you will discover that you need to reference a dll called System.Management.Automation.Dll.  Easy huh?  Numerous blogs mention that you will find this dll in %program files%Windows Powershell V1.0.  Except I'm guessing that was the case in beta versions because it is definitely not the case in the RTM version.

Maybe they put it in the GAC?  From the Visual Studio Add References dialog I searched under the .Net tab and caame up empty.

Not to worry, I fired up my trusty search from Explorer and I was sure I would find it.  I didn't.  I eventually went looking with explorer in WindowsAssembly where the GAC lives.  And lo and behold there it was.  Now how am I supposed to reference it?  Visual Studio doesn't see it, explorer doesn't give me any options to copy it from the GAC to somewhere where Visual Studio can see it. 

Maybe Powershell itself can help.  Once I dug down into C:windowsassemblyGAC_MSILSystem.Management.Automation1.0.0.0__31bf3856ad364e35 I finally found the dll I was looking for.  I copied it elsewhere and then VS could find it.

What's the story here?  Why can't Visual Studio see it?  Why didn't the explorer search find it in the folder I found it in?  Very strange.