{"id":14064293,"url":"https://github.com/jdhitsolutions/PSFunctionInfo","last_synced_at":"2025-07-29T17:33:21.048Z","repository":{"id":145020706,"uuid":"360221896","full_name":"jdhitsolutions/PSFunctionInfo","owner":"jdhitsolutions","description":"A PowerShell module for managing metadata in stand-alone functions. :information_source:","archived":false,"fork":false,"pushed_at":"2024-01-22T13:45:50.000Z","size":1050,"stargazers_count":16,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-21T03:39:39.326Z","etag":null,"topics":["powershell","powershell-functions"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdhitsolutions.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-21T15:37:50.000Z","updated_at":"2024-10-08T13:54:02.000Z","dependencies_parsed_at":"2024-05-27T22:10:47.112Z","dependency_job_id":null,"html_url":"https://github.com/jdhitsolutions/PSFunctionInfo","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhitsolutions%2FPSFunctionInfo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhitsolutions%2FPSFunctionInfo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhitsolutions%2FPSFunctionInfo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhitsolutions%2FPSFunctionInfo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdhitsolutions","download_url":"https://codeload.github.com/jdhitsolutions/PSFunctionInfo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228032926,"owners_count":17858918,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["powershell","powershell-functions"],"created_at":"2024-08-13T07:03:47.894Z","updated_at":"2025-07-29T17:33:21.031Z","avatar_url":"https://github.com/jdhitsolutions.png","language":"PowerShell","funding_links":[],"categories":["PowerShell"],"sub_categories":[],"readme":"# PSFunctionInfo\n\n[![PSGallery Version](https://img.shields.io/powershellgallery/v/PSFunctionInfo.png?style=plastic\u0026logo=powershell\u0026label=PowerShell%20Gallery)](https://www.powershellgallery.com/packages/PSFunctionInfo/) ![PSGallery Downloads](https://img.shields.io/powershellgallery/dt/PSFunctionInfo.png?style=plastic\u0026\u0026logo=powershell\u0026label=Downloads)\n\n## Synopsis\n\n![documents](images/psfunctioninfo-icon.png)\n\nThis module contains a set of PowerShell commands to add and manage metadata in stand-alone PowerShell functions.\n\n## Installation\n\nYou can install this module from the PowerShell Gallery.\n\n```powershell\nInstall-Module PSFunctionInfo -Force [-scope CurrentUser]\n```\n\nOr using `PSResourceGet`:\n\n```powershell\nInstall-PSResource PSFunctionInfo  [-scope CurrentUser]\n```\n\nThe module should work on both Windows PowerShell and PowerShell 7, even cross-platform, except for a few PowerShell ISE related commands.\n\n## Description\n\nThe purpose of this code is to provide a way to get versioning and other metadata information for functions that do not belong to a module. This is information you want to get after the function has been loaded into your PowerShell session. I have numerous stand-alone functions. These functions don't belong to a module, so there is no version or source information. However, I'd like to have that type of information for non-module functions.\n\nThe code in this module isn't concerned with loading, running, or finding functions. By default, [Get-PSFunctionInfo](docs/Get-PSFunctionInfo.md) queries whatever is in the `Function:` PSDrive. If the PowerShell function belongs to a module, then you'll get the module version and source. Otherwise, the command will use the function metadata.\n\n![Get a single function](images/get-psfunctioninfo-1.png)\n\nThe default behavior is to show all functions that __don't__ belong to a module and excluding a few common functions that PowerShell defines.\n\n![Get stand-alone functions](images/get-psfunctioninfo-2.png)\n\nYou can also get currently loaded functions by tag. Use `Get-PSFunctionInfoTag` to get a list of tags currently in use.\n\n![Get functions by tag](images/get-psfunctioninfo-3.png)\n\nThe PSFunctionInfo object includes a PropertySet called `AuthorInfo`.\n\n```dos\nPS C:\\\u003e Get-PSFunctionInfo -Tag modules | Select-Object -property AuthorInfo\n\nName        : Test-HelpLink\nVersion     : 0.9.0\nSource      : C:\\scripts\\update-helplinks.ps1\nCompanyName : JDH IT Solutions, Inc.\nCopyright   : (c) JDH IT Solutions, Inc.\nDescription : Test if help file is missing the online link\nLastUpdate  : 4/23/2024 9:21:00 AM\n```\n\nOr you can use the `TagInfo` property set. This gives you the same result as using the `tag` named view with `Format-Table`.,\n\n```powershell\nGet-PSFunctionInfo | Select-Object taginfo\n```\n\nFinally, you can also search .ps1 files for PSFunctionInfo metadata.\n\n![Get function info from file](images/get-psfunctioninfo-file.png)\n\n## Creating PSFunctionInfo\n\nUse the [New-PSFunctionInfo](docs/New-PSFunctionInfo.md) command to insert the metadata tag into your script file.\n\n```powershell\nNew-PSFunctionInfo -Path c:\\scripts\\Test-ConsoleColors.ps1 -Description \"show console color combinations\" -Name Test-ConsoleColor -Author \"Jeff Hicks\" -CompanyName \"JDH IT Solutions\" -Copyright \"2024 JDH IT Solutions, Inc.\" -Tags \"scripting\",\"console\"\n```\n\nThe default behavior is to insert the metadata tag immediately after the opening brace (`{`) into the file. __This command will update the file__. Or you can use the `ToClipBoard` parameter which will copy the metadata to the clipboard. You can then manually insert it into your script file that defines the function. You should avoid changing the formatting of the comment block.\n\nYou should get something like this:\n\n```text\n\n\u003c# PSFunctionInfo\n\nVersion 1.0.0\nAuthor Jeff Hicks\nCompanyName JDH IT Solutions\nCopyright 2024 JDH IT Solutions, Inc.\nDescription show console color combinations\nGuid 8e43a9d9-1df6-48c7-8595-7363087aba43\nTags scripting,console\nLastUpdate 2/22/2024 10:43 AM\nSource C:\\scripts\\Test-ConsoleColors.ps1\n\n#\u003e\n```\n\nThis command will __not work__ with functions defined in a single line like:\n\n```powershell\nFunction Get-Foo { Get-Date }\n```\n\nHowever, you could run `New-PSFunctionInfo` with the `ToClipboard` parameter and manually edit your function to insert the metadata.\n\n```powershell\nFunction Get-Foo {\n\n\u003c# PSFunctionInfo\n\nVersion 1.0.0\nAuthor Jeff Hicks\nCompanyName JDH IT Solutions\nCopyright 2024 JDH IT Solutions, Inc.\nDescription Get Foo Stuff\nGuid 490595c6-6a0c-4572-baf4-f808c010de70\nTags scripting,console\nLastUpdate 2/21/2024 10:41 AM\nSource C:\\scripts\\FooStuff.ps1\n\n#\u003e\n    Get-Date\n}\n```\n\n### Backup\n\nBecause creating a PSFunctionInfo metadata comment block modifies the file, you might feel safer with a file backup. `New-PSFunctionInfo` has a `-BackupParameter` which will 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 have to manually delete the backup files.\n\nThe `-Backup` parameter has no effect if you use `-Clipboard`.\n\n## PSFunctionInfo Defaults\n\nBecause you might define function metadata often and want to maintain consistency, you can define a set of default values for `New-PSFunctionInfo`. Use the command, [Set-PSFunctionInfoDefaults](docs/Set-PSFunctionInfoDefaults):\n\n```powershell\nSet-PSFunctionInfoDefaults -Tags \"stand-alone\" -Copyright \"(c) JDH IT Solutions, Inc.\" -author \"Jeff Hicks\" -company \"JDH IT Solutions, Inc.\"\n```\n\nThe defaults will be stored in a JSON file (`$HOME\\psfunctioninfo-defaults.json`). When you import this module, the values from this file will be used to define entries in `$PSDefaultParameterValues`. Or, run [Update-PSFunctionInfoDefaults](docs/Update-PSFunctionInfoDefaults) to update parameter defaults.\n\nYou can use [Get-PSFunctionInfoDefaults](docs/Get-PSFunctionInfoDefaults.md) to see the current values.\n\n```powershell\nPS C:\\\u003e Get-PSFunctionInfoDefaults\n\nVersion     : 0.9.0\nCompanyName : JDH IT Solutions, Inc.\nAuthor      : Jeffery Hicks\nTags        : {stand-alone}\nCopyright   : (c) JDH IT Solutions, Inc.\n```\n\n## Editor Integration\n\nWhen you import the module into an editor, you will get additional features to make it easier to insert PSFunctionInfo metadata into your file. It is recommended that you explicitly import the module into the editor's integrated console session. You could add an `Import-Module PSFunctionInfo` command into the editor's PowerShell profile script.\n\n### Visual Studio Code\n\nIf you have an open file, in the integrated PowerShell console, you can run `New-PSFunctionInfo` and press \u003ckbd\u003eTAB\u003c/kbd\u003e to tab-complete the detected functions in the current file. The file path will automatically be detected. You can enter other values such as version, or simply press \u003ckbd\u003eENTER\u003c/kbd\u003e to insert the metadata, which you can then edit.\n\n![VSCode integration](images/psfunctioninfo-vscode.png)\n\nThis example is taking advantage of saved defaults. See [`Set-PSFunctionInfoDefaults`](docs/Set-PSFunctionInfoDefaults.md)\n\n### PowerShell ISE\n\nWhen you import the module in the PowerShell ISE, it will add a menu shortcut.\n\n![ISE Menu](images/ise-psfunction-menu.png)\n\nWith a loaded file, you could run `New-PSFunctionInfo` in the console specifying the function name. The Path will be auto-detected. Or use the menu shortcut which will give you a graphical \"function picker\"\n\n![function picker](images/ise-function-picker.png)\n\nSelect a function and click \u003ckbd\u003eOK\u003c/kbd\u003e. The metadata block will be inserted into the file. This will not work with a file that has unsaved changes. When you insert new function metadata, the file in the ISE will be closed, re-opened and focus should jump to the function.\n\n![ISE metadata](images/ise-psfunctioninfo.png)\n\n### Editing Source Files\n\nThe module has a command called [Edit-PSFunctionInfo](docs/Edit-PSFunctionInfo.md) which will open a source file in your preferred editor. The command has an alias of `epfi`. The default editor selection is VS Code, but you can specify the PowerShell ISE or Notepad.\n\nYou can either specify a loaded function by name:\n\n```powershell\nEdit-PSFunctionInfo Get-QOTD\n```\n\nOr pipe to it.\n\n```powershell\nGet-PSFunctionInfo Get-QOTD | Edit-PSFunctionInfo -editor ise\n```\n\nOnce opened, you will need to navigate to the appropriate function and metadata section.\n\nIt is assumed you will normally edit function metadata when editing the script file. But you can use [`Set-PSFunctionInfo](docs/Set-PSFunctionInfo.md) to make changes from the console.\n\n```powershell\nPS C:\\\u003e Set-PSFunctionInfo -Name Get-EventlogInfo -Path c:\\work\\LogTools.ps1 -Tags \"profile,eventlog\" -Version \"1.2.1\"\n```\n\nIf you want to clear an existing value, set the parameter value to `$null`.\n\n```powershell\nPS C:\\\u003e Set-PSFunctionInfo -Name Get-EventlogInfo -Path c:\\work\\LogTools.ps1 -Source $null\n```\n\n## Background\n\nThis code is a prototype for a [suggestion](https://github.com/PowerShell/PowerShell/issues/11667) I made for PowerShell 7. Early versions of this code were published as [https://gist.github.com/jdhitsolutions/65070cd51b5cfb572bc6375f67bcbc3d](https://gist.github.com/jdhitsolutions/65070cd51b5cfb572bc6375f67bcbc3d \"view the Github gist\")\n\nThis module was first described at \u003chttps://jdhitsolutions.com/blog/powershell/8343/a-better-way-to-manage-powershell-functions/\u003e.\n\n## Related Modules\n\n:bulb: You might also be interested in the [PSFunctionTools](https://github.com/jdhitsolutions/PSFunctionTools) module which contains a set of PowerShell 7 tools for automating and accelerating script and module development.\n\n## Roadmap\n\n- Add function metadata by file, auto-detecting the function name.\n- Consider a bulk removal command to clean PSFunctionInfo metadata from files.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdhitsolutions%2FPSFunctionInfo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdhitsolutions%2FPSFunctionInfo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdhitsolutions%2FPSFunctionInfo/lists"}