Skip to content

Commit 608fe5d

Browse files
initial files
0 parents  commit 608fe5d

29 files changed

+3009
-0
lines changed

License.txt

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
MIT License
2+
3+
Copyright (c) 2021 JDH Information Technology Solutions, Inc.
4+
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
14+
The above copyright notice and this permission notice shall be included in
15+
all copies or substantial portions of the Software.
16+
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
THE SOFTWARE.

PSFunctionTools.psd1

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
#
2+
# Module manifest for module 'PSFunctionTools'
3+
#
4+
# Generated by: Jeff Hicks
5+
#
6+
# Generated on: 12/14/2021
7+
#
8+
9+
@{
10+
11+
# Script module or binary module file associated with this manifest.
12+
RootModule = 'C:\Scripts\PSFunctionTools\PSFunctionTools.psm1'
13+
14+
# Version number of this module.
15+
ModuleVersion = '0.1.0'
16+
17+
# Supported PSEditions
18+
CompatiblePSEditions = 'Desktop', 'Core'
19+
20+
# ID used to uniquely identify this module
21+
GUID = '151466e0-a952-4b6a-ad81-40dafc9ef9bb'
22+
23+
# Author of this module
24+
Author = 'Jeff Hicks'
25+
26+
# Company or vendor of this module
27+
CompanyName = 'JDH Information Technology Solutions, Inc.'
28+
29+
# Copyright statement for this module
30+
Copyright = '(c) 2021 JDH Information Technology Solutions, Inc.'
31+
32+
# Description of the functionality provided by this module
33+
Description = 'A set of PowerShell commands for working with PowerShell scripts and functions.'
34+
35+
# Minimum version of the PowerShell engine required by this module
36+
PowerShellVersion = '5.1'
37+
38+
# Name of the PowerShell host required by this module
39+
# PowerShellHostName = ''
40+
41+
# Minimum version of the PowerShell host required by this module
42+
# PowerShellHostVersion = ''
43+
44+
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
45+
# DotNetFrameworkVersion = ''
46+
47+
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
48+
# ClrVersion = ''
49+
50+
# Processor architecture (None, X86, Amd64) required by this module
51+
# ProcessorArchitecture = ''
52+
53+
# Modules that must be imported into the global environment prior to importing this module
54+
# RequiredModules = @()
55+
56+
# Assemblies that must be loaded prior to importing this module
57+
# RequiredAssemblies = @()
58+
59+
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
60+
# ScriptsToProcess = @()
61+
62+
# Type files (.ps1xml) to be loaded when importing this module
63+
# TypesToProcess = @()
64+
65+
# Format files (.ps1xml) to be loaded when importing this module
66+
# FormatsToProcess = @()
67+
68+
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
69+
# NestedModules = @()
70+
71+
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
72+
FunctionsToExport = 'Test-FunctionName', 'Get-FunctionName', 'Get-FunctionAlias',
73+
'Export-FunctionFromFile', 'Export-ModuleLayout',
74+
'Import-ModuleLayout', 'Convert-ScriptToFunction',
75+
'Get-PSRequirements', 'New-CommentHelp', 'Format-FunctionName'
76+
77+
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
78+
CmdletsToExport = @()
79+
80+
# Variables to export from this module
81+
# VariablesToExport = @()
82+
83+
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
84+
AliasesToExport = 'gfal', 'ga', 'eff', 'eml', 'iml', 'csf'
85+
86+
# DSC resources to export from this module
87+
# DscResourcesToExport = @()
88+
89+
# List of all modules packaged with this module
90+
# ModuleList = @()
91+
92+
# List of all files packaged with this module
93+
# FileList = @()
94+
95+
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
96+
PrivateData = @{
97+
98+
PSData = @{
99+
100+
# Tags applied to this module. These help with module discovery in online galleries.
101+
# Tags = @()
102+
103+
# A URL to the license for this module.
104+
# LicenseUri = ''
105+
106+
# A URL to the main website for this project.
107+
# ProjectUri = ''
108+
109+
# A URL to an icon representing this module.
110+
# IconUri = ''
111+
112+
# ReleaseNotes of this module
113+
# ReleaseNotes = ''
114+
115+
# Prerelease string of this module
116+
# Prerelease = ''
117+
118+
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
119+
# RequireLicenseAcceptance = $false
120+
121+
# External dependent modules of this module
122+
# ExternalModuleDependencies = @()
123+
124+
} # End of PSData hashtable
125+
126+
} # End of PrivateData hashtable
127+
128+
# HelpInfo URI of this module
129+
# HelpInfoURI = ''
130+
131+
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
132+
# DefaultCommandPrefix = ''
133+
134+
}
135+

PSFunctionTools.psm1

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
Get-Childitem $psscriptroot\functions\*.ps1 -recurse |
3+
Foreach-Object {
4+
. $_.FullName
5+
}
6+

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# README

changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Changelog

docs/Convert-ScriptToFunction.md

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
external help file: PSFunctionTools-help.xml
3+
Module Name: PSFunctionTools
4+
online version:
5+
schema: 2.0.0
6+
---
7+
8+
# Convert-ScriptToFunction
9+
10+
## SYNOPSIS
11+
Convert a script file to a PowerShell function.
12+
13+
## SYNTAX
14+
15+
```
16+
Convert-ScriptToFunction [-Path] <String> [-Name] <String> [-Alias <String[]>] [<CommonParameters>]
17+
```
18+
19+
## DESCRIPTION
20+
This command takes the body of a script file and wraps it in a function
21+
declaration.
22+
The command will insert missing elements like \[cmdletbinding()\]
23+
and comment-based help.
24+
You will most likely need to edit and clean up the
25+
result in your scripting editor.
26+
27+
If you run this command in the PowerShell ISE or the VS Code PowerShell
28+
integrated terminal, you can use the dynamic parameter ToEditor to open a
29+
new file with with the output.
30+
You can edit and save the file manually.
31+
32+
It is assumed that your script file is complete and without syntax errors.
33+
34+
## EXAMPLES
35+
36+
### EXAMPLE 1
37+
```
38+
Convert-ScriptToFunction c:\scripts\Daily.ps1 -name Invoke-DailyTask | Set-Clipboard
39+
```
40+
41+
Convert Daily.ps1 to a function called Invoke-DailyTask and copy the
42+
results to the Windows clipboard.
43+
You can then paste the results into
44+
scripting editor.
45+
46+
### EXAMPLE 2
47+
```
48+
Convert-ScriptToFunction c:\scripts\systemreport.ps1 -name New-SystemReport | Out-File c:\scripts\New-SystemReport.ps1
49+
```
50+
51+
Convert the SystemReport.ps1 script file to a function called
52+
New-SystemReport and save the results to a file.
53+
54+
### EXAMPLE 3
55+
```
56+
Convert-ScriptToFunction c:\scripts\systemreport.ps1 -name New-System -alias nsr | Tee-Object -variable f
57+
```
58+
59+
Convert the script to a function called New-System and tee the output to $f.
60+
This will also define an function alias of nsr.
61+
62+
## PARAMETERS
63+
64+
### -Path
65+
Enter the path to your PowerShell script file.
66+
67+
```yaml
68+
Type: String
69+
Parameter Sets: (All)
70+
Aliases:
71+
72+
Required: True
73+
Position: 1
74+
Default value: None
75+
Accept pipeline input: True (ByPropertyName)
76+
Accept wildcard characters: False
77+
```
78+
79+
### -Name
80+
What is the name of your new function?
81+
It should have a Verb-Noun name.
82+
83+
```yaml
84+
Type: String
85+
Parameter Sets: (All)
86+
Aliases:
87+
88+
Required: True
89+
Position: 2
90+
Default value: None
91+
Accept pipeline input: True (ByPropertyName)
92+
Accept wildcard characters: False
93+
```
94+
95+
### -Alias
96+
Define an optional alias for your new function.
97+
98+
```yaml
99+
Type: String[]
100+
Parameter Sets: (All)
101+
Aliases:
102+
103+
Required: False
104+
Position: Named
105+
Default value: None
106+
Accept pipeline input: True (ByPropertyName)
107+
Accept wildcard characters: False
108+
```
109+
110+
### CommonParameters
111+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
112+
113+
## INPUTS
114+
115+
## OUTPUTS
116+
117+
### System.String
118+
## NOTES
119+
120+
## RELATED LINKS

0 commit comments

Comments
 (0)