Author Posts

May 2, 2016 at 10:59 am

How I can see source code of functions that are included in third party PowerShell module?

I want to see code for Get-CMSoftwareUpdate (this command is from sccm powershell module)

May 2, 2016 at 11:21 am

Depends on how the command was written. You've got three main types:

– PowerShell functions. These are easy, since the function "is" the source code. You can do something like this to open the file up in the ise, if the command is a function: powershell_ise (Get-Command Get-CMSoftwareUpdate).ScriptBlock.File

– Cmdlets. These are .NET classes, usually written in C#. Unless the source code is open-source, you can't get its original form, but you can decompile back to a somewhat-readable C# file using free tools such as ILSpy or DotPeek. If it's a cmdlet, you can find the file that needs to be decompiled like this: (Get-Command Get-CMSoftwareUpdate).ImplementingType.Assembly.Location

– CIM commands. These are auto-generated PowerShell wrappers around WMI classes; they're generated from cdxml files in the module directory. I'm not sure if there's an easy way to open an individual command's file, but once you know that's what you're dealing with, you can browse to the module's folder and open up the cdxml files to see what it's doing.

May 2, 2016 at 12:08 pm

Dave really you are awesome. it helped me.