Это работает, вы просто должны убедиться, что у вас есть правильные заголовки. Я всегда помещал блок комментариев прямо над функцией тоже. Я не уверен, должен ли он работать внутри функции или нет.
Ниже приведен пример одной из моих функций, в которой есть справка о рабочем документе.
##############################################################################
#.SYNOPSIS
# Gets a COM object from the running object table (ROT) similar to GetObject
# in Visual Basic.
#
#.DESCRIPTION
# To maintain consistency with New-Object this cmdlet requires the -ComObject
# parameter to be provided and the TypeName parameter is not supported.
#
#.PARAMETER TypeName
# Not supported, but provided to maintain consistency with New-Object.
#
#.PARAMETER ComObject
# The ProgID of a registered COM object, such as MapPoint.Application.
#
#.PARAMETER Force
# If an existing object is not found, instead of writing an error, a new
# instance of the object will be created and returned.
#
#.EXAMPLE
# $olMailItem = 0
# Get-Object -ComObject Outlook.Application | %{$_.CreateItem($olMailItem).Display()}
##############################################################################
function Get-Object {
[CmdletBinding(DefaultParameterSetName='Net')]
param (
[Parameter(ParameterSetName='Net', Position=1, Mandatory=$true)]
[String]$TypeName,
[Parameter(ParameterSetName='Com', Mandatory=$true)]
[String]$ComObject,
[Parameter()]
[Switch]$Force
)
if ( $TypeName ) { throw '-TypeName is not supported. Use -ComObject instead.' }
if ( $ComObject ) {
try {
[System.Runtime.InteropServices.Marshal]::GetActiveObject($ComObject)
}
catch [System.Management.Automation.MethodInvocationException] {
if ( $Force ) { New-Object -ComObject $ComObject }
else { Write-Error "An active object of type $ComObject is not available." }
}
}
}