Skip to content

Commit 37e694a

Browse files
v1.0.0
1 parent 3318599 commit 37e694a

14 files changed

+534
-15
lines changed

PSFunctionTools.psd1

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
#
44

55
@{
6-
76
RootModule = 'PSFunctionTools.psm1'
8-
ModuleVersion = '0.6.0'
7+
ModuleVersion = '1.0.0'
98
CompatiblePSEditions = 'Core'
109
GUID = '151466e0-a952-4b6a-ad81-40dafc9ef9bb'
1110
Author = 'Jeff Hicks'
@@ -26,24 +25,23 @@
2625
'Get-PSRequirements', 'New-CommentHelp', 'Format-FunctionName',
2726
'Get-ModuleLayout', 'Get-ParameterBlock', 'Get-FunctionAttribute',
2827
'Get-FunctionProfile', 'New-ModuleFromFiles', 'New-ModuleFromLayout',
29-
'Get-PSFunctionTools')
28+
'Get-PSFunctionTools','Export-FunctionToFile')
3029
CmdletsToExport = @()
3130
# VariablesToExport = @()
3231
AliasesToExport = @('gfal', 'ga', 'eff', 'eml', 'iml', 'csf', 'gpb',
33-
'gfa', 'nch', 'ffn', 'gfn', 'tfn', 'gfp')
32+
'gfa', 'nch', 'ffn', 'gfn', 'tfn', 'gfp','etf')
3433
PrivateData = @{
3534

3635
PSData = @{
37-
Tags = @('AST', 'scripting', 'module', 'function','script')
36+
Tags = @('AST', 'scripting', 'module', 'function', 'script')
3837
LicenseUri = 'https://github.com/jdhitsolutions/PSFunctionTools/blob/main/License.txt'
3938
ProjectUri = 'https://github.com/jdhitsolutions/PSFunctionTools'
40-
# IconUri = ''
39+
IconUri = 'https://raw.githubusercontent.com/jdhitsolutions/PSFunctionTools/main/images/psrobot.png'
4140
# ReleaseNotes = ''
4241
# Prerelease = ''
4342
# ExternalModuleDependencies = @()
4443

4544
} # End of PSData hashtable
46-
4745
} # End of PrivateData hashtable
4846
}
4947

README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The commands in this module have been developed to make it easier to automate th
1010
+ [Fun with PowerShell Module Layout](https://jdhitsolutions.com/blog/powershell/8731/fun-with-powershell-module-layout/)
1111
+ [Building a PowerShell Module Inception-Style](https://jdhitsolutions.com/blog/powershell/8741/building-a-powershell-module-inception-style/)
1212

13-
This module has been written for PowerShell 7.1 and later. It is most likely that the the commands will work in Windows PowerShell, but you will need to fork this module and revise as necessary. Otherwise, install this module from the PowerShell Gallery.
13+
This module has been written for **PowerShell 7.1** and later. It is most likely that the the commands will work in Windows PowerShell, but you will need to fork this module and revise as necessary. Otherwise, install this module from the PowerShell Gallery.
1414

1515
```powershell
1616
Install-Module PSFunctionTools
@@ -23,17 +23,19 @@ To see a summary of these commands at any time, run [Get-PSFunctionTools](docs/G
2323
```dos
2424
PS C:\> Get-PSFunctionTools
2525
26-
Module: PSFunctionTools [v0.6.0]
26+
Module: PSFunctionTools [v1.0.0]
2727
2828
Name Alias Synopsis
2929
---- ----- --------
3030
Convert-ScriptToFunction csf Convert a script file to a PowerShell funct…
3131
Export-FunctionFromFile eff Export a PowerShell function from a script …
32+
Export-FunctionToFile etf Export a PowerShell function to a file.
3233
Export-ModuleLayout eml Export a model module layout.
33-
Format-FunctionName Format a function name to proper case.
34+
Format-FunctionName ffn Format a function name to proper case.
3435
Get-FunctionAlias {ga, gfal} Get a defined function alias.
3536
Get-FunctionAttribute gfa Get function attributes like cmdletbinding.
36-
Get-FunctionName Identify the names of PowerShell functions …
37+
Get-FunctionName gfn Identify the names of PowerShell functions …
38+
Get-FunctionProfile gfp Get a technical summary of a PowerShell fun…
3739
Get-ModuleLayout Get information about a module layout file.
3840
Get-ParameterBlock gpb Get a function's parameter block.
3941
Get-PSFunctionTools Get a summary of PSFunctionTools commands.
@@ -42,7 +44,7 @@ Import-ModuleLayout iml Create a module structure from a layout fil
4244
New-CommentHelp nch Create comment based help.
4345
New-ModuleFromFiles Create a PowerShell module from a set of fi…
4446
New-ModuleFromLayout Creat a new module based on a layout.
45-
Test-FunctionName Test the validity of a PowerShell function …
47+
Test-FunctionName tfn Test the validity of a PowerShell function …
4648
```
4749

4850
### [Convert-ScriptToFunction](docs/Convert-ScriptToFunction.md)
@@ -67,6 +69,16 @@ Export-FunctionFromFile C:\scripts\MyInternetTools.psm1 -Name get-zipinfo -Outpu
6769

6870
If you run this command in the PowerShell ISE or the VS Code integrated PowerShell Terminal, you can use the dynamic parameter `Remove` to delete the function from the source file.
6971

72+
### [Export-FunctionToFile](docs/Export-FunctionToFile.md)
73+
74+
You +can use this command to export a function which is loaded into your PowerShell session. You might need to do this when you create an ad-hoc function and want to save it to a file. This command will take the content of the function and export it to a ps1 file. The function name will be used for the file name. Although, characters like the colon will be stripped to create a filesystem-compatibale filename.
75+
76+
You can also include `#Requires` statements.
77+
78+
```powershell
79+
Export-FunctionToFile -Name New-FileLink -Path c:\scripts -Requires "#requires -version 5.1","#requires -RunAsAdministrator"
80+
```
81+
7082
### [Export-ModuleLayout](docs/Export-ModuleLayout.md)
7183

7284
Use `Export-ModuleLayout` to export a model module directory structure to a json file. You can use `Import-ModuleLayout` to recreate the layout from the json file. The export process will include not only directories, but also text files like a readme or license file.

changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog for PSFunctionTools
22

3+
## v1.0.0
4+
5+
+ Added online help links for previously published commands.
6+
+ Bumped version number to reflect feature-complete release.
7+
+ Added `Export-FunctionToFile` to export a loaded function from your session to a script file.
8+
+ Help updates.
9+
+ Updated `README.md`.
10+
311
## v0.6.0
412

513
+ Added online help links for previously published commands.

docs/Export-FunctionFromFile.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,5 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell
211211
## RELATED LINKS
212212
213213
[Get-FunctionName](Get-FunctionName.md)
214+
215+
[Export-FunctionToFile](Export-FunctionToFile.md)

docs/Export-FunctionToFile.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
---
2+
external help file: PSFunctionTools-help.xml
3+
Module Name: PSFunctionTools
4+
online version:
5+
schema: 2.0.0
6+
---
7+
8+
# Export-FunctionToFile
9+
10+
## SYNOPSIS
11+
12+
Export a PowerShell function to a file.
13+
14+
## SYNTAX
15+
16+
```yaml
17+
Export-FunctionToFile [-Name] <String> [-Path <String>] [-Passthru] [-Requires <String[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
18+
```
19+
20+
## DESCRIPTION
21+
22+
You can use this command to export a function which is loaded into your PowerShell session. You might need to do this when you create an ad-hoc function and want to save it to a file. This command will take the content of the function and export it to a ps1 file. The function name will be used for the file name. Although, characters like the colon will be stripped to create a filesystem-compatibale filename.
23+
24+
## EXAMPLES
25+
26+
### Example 1
27+
28+
```powershell
29+
PS C:\> Export-FunctionToFile -Name prompt -Path c:\scripts
30+
```
31+
32+
Get the prompt function from your PowerShell session and export it to C:\Scripts. The filename will be prompt.ps1
33+
34+
### Example 2
35+
36+
```powershell
37+
PS C:\> Export-FunctionToFile -Name New-FileLink -Path c:\work -Requires "#requires -version 5.1","#requires -RunAsAdministrator" -Passthru
38+
39+
Directory: C:\work
40+
41+
Mode LastWriteTime Length Name
42+
---- ------------- ------ ----
43+
-a--- 2/28/2022 1:28 PM 1987 New-FileLink.ps1
44+
```
45+
46+
Export the New-FileLInk function to a file and specify runtime requirements.
47+
48+
## PARAMETERS
49+
50+
### -Confirm
51+
52+
Prompts you for confirmation before running the cmdlet.
53+
54+
```yaml
55+
Type: SwitchParameter
56+
Parameter Sets: (All)
57+
Aliases: cf
58+
59+
Required: False
60+
Position: Named
61+
Default value: None
62+
Accept pipeline input: False
63+
Accept wildcard characters: False
64+
```
65+
66+
### -Name
67+
68+
Specify the name of a function loaded in your PowerShell session.
69+
70+
```yaml
71+
Type: String
72+
Parameter Sets: (All)
73+
Aliases:
74+
75+
Required: True
76+
Position: 0
77+
Default value: None
78+
Accept pipeline input: True (ByValue)
79+
Accept wildcard characters: False
80+
```
81+
82+
### -Passthru
83+
84+
Show the file result.
85+
86+
```yaml
87+
Type: SwitchParameter
88+
Parameter Sets: (All)
89+
Aliases:
90+
91+
Required: False
92+
Position: Named
93+
Default value: None
94+
Accept pipeline input: False
95+
Accept wildcard characters: False
96+
```
97+
98+
### -Path
99+
100+
Specify the location for the new file. The function name will be used for the file name, stripping off any characters that invalid filename characters.
101+
102+
```yaml
103+
Type: String
104+
Parameter Sets: (All)
105+
Aliases:
106+
107+
Required: False
108+
Position: Named
109+
Default value: None
110+
Accept pipeline input: False
111+
Accept wildcard characters: False
112+
```
113+
114+
### -Requires
115+
116+
Specify #Requires statements, including the #
117+
118+
```yaml
119+
Type: String[]
120+
Parameter Sets: (All)
121+
Aliases:
122+
123+
Required: False
124+
Position: Named
125+
Default value: None
126+
Accept pipeline input: False
127+
Accept wildcard characters: False
128+
```
129+
130+
### -WhatIf
131+
132+
Shows what would happen if the cmdlet runs.
133+
The cmdlet is not run.
134+
135+
```yaml
136+
Type: SwitchParameter
137+
Parameter Sets: (All)
138+
Aliases: wi
139+
140+
Required: False
141+
Position: Named
142+
Default value: None
143+
Accept pipeline input: False
144+
Accept wildcard characters: False
145+
```
146+
147+
### CommonParameters
148+
149+
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).
150+
151+
## INPUTS
152+
153+
### System.String
154+
155+
## OUTPUTS
156+
157+
### None
158+
159+
### System.IO.FileInfo
160+
161+
## NOTES
162+
163+
Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/
164+
165+
## RELATED LINKS
166+
167+
[Export-FunctionFromFile](Export-FunctionFromFile.md)

docs/Get-FunctionProfile.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
external help file: PSFunctionTools-help.xml
33
Module Name: PSFunctionTools
4-
online version:
4+
online version: https://bit.ly/325JY1E
55
schema: 2.0.0
66
---
77

docs/Get-PSFunctionTools.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
external help file: PSFunctionTools-help.xml
33
Module Name: PSFunctionTools
4-
online version:
4+
online version: https://bit.ly/3Kipd3Y
55
schema: 2.0.0
66
---
77

0 commit comments

Comments
 (0)