external help file | Module Name | online version | schema |
---|---|---|---|
PSFunctionInfo-help.xml |
PSFunctionInfo |
2.0.0 |
Create PowerShell function metadata.
New-PSFunctionInfo [-Name] <String> -Path <String> [-Author <String>] [-CompanyName <String>] [-Copyright <String>] [-Description <String>] [-Version <String>] [-Tags <String[]>] [-ToClipboard] [-Backup] [-NoSource] [-WhatIf] [-Confirm] [<CommonParameters>]
This command will create a function metadata comment block and insert it into the source script file. Or you can copy it to the clipboard and insert it yourself. There are no commands to modify or remove the function metadata once it has been inserted into the file. It is assumed that if you update the function, you can manually update (or remove) the metadata at the same time.
NOTE: This command will not work properly with one-line function declarations like Function Get-This { Get-Date }. It is also expected that you don't have multiple versions of the function in the same file. DO NOT modify spacing or formatting of the function metadata.
PS C:\> New-PSFunctionInfo -Path c:\scripts\Test-ConsoleColors.ps1 -Description "show console color combinations" -Name Test-ConsoleColor -Author "Jeff Hicks" -CompanyName "JDH IT Solutions" -Copyright "2025 JDH IT Solutions, Inc." -Tags "scripting","console" -backup
Insert function metadata into the script file before the [cmdletbinding()] tag. This example will produce this comment block:
PSFunctionInfo
Version 1.0.0
Author Jeff Hicks
CompanyName JDH IT Solutions
Copyright 2025 JDH IT Solutions, Inc.
Description show console color combinations
Guid e07e256e-a2d6-4acc-a1cf-5d8d1be7db27
Tags scripting,console
LastUpdate 03/02/2025 10:34:18
Source C:\Scripts\Test-ConsoleColors.ps1
This example will also create a backup copy of the source file at c:\scripts\Test-ConsoleColors.ps1.bak1.
PS C:\> New-PSFunctionInfo -Path c:\scripts\Test-ConsoleColors.ps1 -Description "show console color combinations" -Name Test-ConsoleColor -Author "Jeff Hicks" -CompanyName "JDH IT Solutions" -Copyright "2025 JDH IT Solutions, Inc." -Tags "scripting","console" -ToClipboard
This will create the same metadata as the first example. Except it will be copied to the clipboard and not to the file.
Specify the function author.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: Current user name
Accept pipeline input: False
Accept wildcard characters: False
Specify a company or organization.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Prompts you for confirmation before running the cmdlet.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Specify a copyright for the function.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: The current year
Accept pipeline input: False
Accept wildcard characters: False
Specify a brief function description.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specify the name of the function.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specify the path to the .ps1 file that contains the function. The path must end in .ps1.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specify an array of optional tags.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Copy the metadata to the clipboard. The file is left untouched.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: clip
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Specify a version number. It is recommended to use a semantic version numbering.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: 1.0.0
Accept pipeline input: False
Accept wildcard characters: False
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Create a backup copy of the source file before inserting the metadata comment block. The file will be created in the same directory, appending an extension of .bak1. If there are previous backups, the number will increment, i.e. .bak2. You can manually delete the backup files.
This parameter has no effect if you use -Clipboard.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Do not insert the source file path into the metadata comment block.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
This function has an alias of npfi.
Learn more about PowerShell: https://jdhitsolutions.com/yourls/newsletter