Extract .SYNOPSIS from Powershell Function

Hi all
Is there a way to extract only the .SYNOPSIS part from function?
I have this function which shows all the functions and aliases within a module (SIT-ADFunctions)
Function Show-SITFunctions()
{
    $functions = Get-Command -Module SIT-ADFunctions
    cls

        $obj = @()
        foreach($ffunction in $functions)
        {
            $funcName = $ffunction.Name

            $falias = Get-Alias -Definition $funcName
            $falias = $falias.name

            $memb = New-Object System.Object
            $memb | Add-Member -Type NoteProperty -name "Function" -value $funcName
            $memb | Add-Member -type NoteProperty -name "Alias" -value $fAlias

            $obj += $memb
         }

    $obj | Format-Table Function,Alias
}

Open in new window

It gives this
Function                 Alias
--------                 -----
Get-SITCU                gcu
Get-SITDagensTal         dt
Get-SITDomainAdmins      gda
Get-SITEmptyFields       gef
Get-SITEnterpriseAdmins  gea
Get-SITFSMORoleOwner     fsmo
Get-SITGroupMembers      ggm
Get-SITGroupMemberships  ggms
Get-SITGroupsAndUsers    ggau
Get-SITInactiveComputers gic
Get-SITLocalAdmin        gla
Get-SITMaxTokenSize      gts

Open in new window

I would like to also show the SYNOPSIS from each function. Is it possible?
Kasper KatzmannSeniorkonsulentAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
Basically with something like (Get-Help -Name Whatever).synopsis.
But there's no need for all the intermediate variables, and in principle, the function shouldn't return anything resulting from a Format-* cmdlet. You can't do anything anymore with those results.
It's still in the following script, but I'd really recommend to remove it and return the plain objects.
This allows you to do something like
Show-SITFunctions | ft -au
Show-SITFunctions | fl
Show-SITFunctions | ? {$_.Name -like 'Whatever'}

Open in new window

which isn't possible if the function already formats the results.
Anyway, here's how I'd do it:
Function Show-SITFunctions() {
	Get-Command -Module SIT-ADFunctions | ForEach-Object {
		$ReturnObject = '' | Select-Object -Property Function, Alias, Synopsis
		$ReturnObject.Function = $_.Name
		$ReturnObject.Alias = Get-Alias -Definition $_.Name -ErrorAction SilentlyContinue
		$ReturnObject.Synopsis = (Get-Help -Name $_.Name -ErrorAction SilentlyContinue).synopsis
		$ReturnObject
	} | Format-Table -AutoSize
}

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kasper KatzmannSeniorkonsulentAuthor Commented:
Brilliant. Exactly what i needen only better :)
Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.