Is there an method for marking script module functions deprecated?

I am planning to phase out some script module functions and would like to mark them as deprecated for a couple of modules versions before pulling them out. Is there any option for doing this in PowerShell script type modules? If there is no specific language feature are there any common conventions like noting the deprecation in comment based help maybe.

Not that I’m aware of.

If you’re replacing it with something else then I guess you could add an alias on the function that replaces it.
Then you can check if the alias or the new function name was used and display some message saying that the old function have been replaced.

To check if the alias is used you could do:

[pre]
$MyInvocation.InvocationName
[/pre]

I’ve not seen anything that would deprecate a function, but you could add some warnings to the PSM1 and the functions to indicate they are being deprecated which would still have the function return data as normal but throw a warning message:

function Test-It {
    param()
    begin{}
    process{}
    end{
        [pscustomobject]@{Name='Bill Johnson';Hobby='Curling', 'Kittens'}
        Write-Warning -Message ('{0} will be deprecated. Please change your code to use Test-That' -f $MyInvocation.MyCommand.Name)
    }
}

Test-It

Output:

WARNING: Test-It will be deprecated. Please change your code to use Test-That
Name         Hobby             
----         -----             
Bill Johnson {Curling, Kittens}

The Write-Warning idea seems easy enough. I’ll try that out.