Open dEhiN opened 6 months ago
Putting this on hold for now, but pasting here the example given in the above article for commenting functions so the cmdlet Get-Help
will return correct output about the function:
function Add-Extension
{
param ([string]$Name,[string]$Extension = "txt")
$name = $name + "." + $extension
$name
<#
.SYNOPSIS
Adds a file name extension to a supplied name.
.DESCRIPTION
Adds a file name extension to a supplied name.
Takes any strings for the file name or extension.
.PARAMETER Name
Specifies the file name.
.PARAMETER Extension
Specifies the extension. "Txt" is the default.
.INPUTS
None. You can't pipe objects to Add-Extension.
.OUTPUTS
System.String. Add-Extension returns a string with the extension or file name.
.EXAMPLE
PS> Add-Extension -name "File"
File.txt
.EXAMPLE
PS> Add-Extension -name "File" -extension "doc"
File.doc
.EXAMPLE
PS> Add-Extension "File" "doc"
File.doc
.LINK
Online version: http://www.fabrikam.com/add-extension.html
.LINK
Set-Item
#>
}
According to the article, running the command PS> Get-Help Add-Extension -full
then produces the following output:
NAME
Add-Extension
SYNOPSIS
Adds a file name extension to a supplied name.
SYNTAX
Add-Extension [[-Name] <String>] [[-Extension] <String>] [<CommonParameters>]
DESCRIPTION
Adds a file name extension to a supplied name. Takes any strings for the file name or extension.
PARAMETERS
-Name
Specifies the file name.
Required? false
Position? 0
Default value
Accept pipeline input? false
Accept wildcard characters?
-Extension
Specifies the extension. "Txt" is the default.
Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters?
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug,
-ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
-OutBuffer and -OutVariable. For more information, type
"get-help about_commonparameters".
INPUTS
None. You can't pipe objects to Add-Extension.
OUTPUTS
System.String. Add-Extension returns a string with the extension or file name.
-------------------------- EXAMPLE 1 --------------------------
PS> Add-Extension -name "File"
File.txt
-------------------------- EXAMPLE 2 --------------------------
PS> Add-Extension -name "File" -extension "doc"
File.doc
-------------------------- EXAMPLE 3 --------------------------
PS> Add-Extension "File" "doc"
File.doc
RELATED LINKS
Online version: http://www.fabrikam.com/add-extension.html
Set-Item
The current (as of 2024-03-01) script and function comments and definitions are:
# Main PowerShell script for CompStart
# This version is a copy being used while working on the feature branch:
# features/startup_data_modifier_tool
# Function to run a specific startup item
# Input: 1. A String representing the full file path + program name with
# extension of the startup item
# 2. A String representing the full arguments list to pass to
# this startup item when calling it
# 3. A Int32 representing which startup item number this item is
function Start-StartupItem {
param (
[Parameter(Mandatory)]
[int32]$StartItemNumber,
[Parameter(Mandatory)]
[string]$ProgramPath,
[string]$ArgumentsList = $null
)
...
}
# Function to process all the data for a specific startup item
# Input: 1. A PSCustomObject containing all the JSON data for a single
# startup item
function Get-StarupItem {
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[PSCustomObject]$StartupItem
)
...
}
Some changes were made to the function (cmdlet) Start-StartupItem
while working on issue #25. The changes were reset to what's listed above, so they are being pasted here for when this issue is being worked on:
# This function will take a program path passed in and run it using the Start-Process cmdlet. If an argument list is passed in, that will be passed to the cmdlet. This is used by the script to start each startup item stored in the file startup_data.json
# Input: 1. (Optional) A Int32 representing which startup item number this item is. Currently this parameter isn't used by the function, as of 2024-03-31 but is kept in the script for possible future use.
# 2. A String representing the full file path + program name with
# extension of the startup item
# 3. A String representing the full arguments list to pass to
# this startup item when calling it. It defaults to $null if nothing is passed in.
While testing things in the feature branch features/startup_data_modifier_tool, realized that the current function comments - the comments explaining what each one does in
startup.ps1
- were quickly put together. Looked up the PowerShell way to comment functions and scripts and found the following Microsoft Learn article:https://learn.microsoft.com/en-us/powershell/scripting/developer/help/examples-of-comment-based-help?view=powershell-7.4