external help file | Module Name | online version | schema |
---|---|---|---|
PSFunctionTools-help.xml |
PSFunctionTools |
2.0.0 |
Export a PowerShell function from a script file.
Export-FunctionFromFile [-Path] <String> [-OutputPath <String>] [-PassThru]
[-Remove] [-WhatIf] [-Confirm] [<CommonParameters>]
Export-FunctionFromFile [-Path] <String> [-OutputPath <String>]
[-Name <String[]>] [-PassThru] [-Remove] [-WhatIf] [-Confirm] [<CommonParameters>]
Export-FunctionFromFile [-Path] <String> [-OutputPath <String>] [-All] [-Remove] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
You should use Export-FunctionFromFile when you want to export PowerShell functions defined in in a single script file, placing each function in its own file. You might want to do this to build or restructure a PowerShell module.
You can export all functions from a file or specific functions. The default behavior is to only export functions that follow a standard verb-noun naming convention. The source must be a .ps1 or .psm1 script file.
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.
PS C:\> Export-FunctionFromFile C:\scripts\MyInternetTools.psm1 -Name get-zipinfo -OutputPath c:\scripts\psinternettools\functions
Export the Get-ZipInfo function from C:\scripts\MyInternetTools.psm1 to its own file. The original file remains unchanged.
PS C:\> Export-FunctionFromFile C:\scripts\MyInternetTools.psm1 -OutputPath c:\scripts\psinternettools\functions
Export all functions that follow the verb-noun naming convention to separate files under C:\Scripts\PSInternetTools\Functions.
Export all detected functions regardless of name.
Type: SwitchParameter
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: None
Accept pipeline input: False
Accept wildcard characters: False
Specify a function by name.
Type: String[]
Parameter Sets: byName
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specify the output path. The default is the same directory as the .ps1 file.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Pass the output file to the pipeline.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specify the .ps1 or .psm1 file with defined functions.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 0
Default value: None
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: None
Accept pipeline input: False
Accept wildcard characters: False
This is a dynamic parameter that is only available if you are running this command in the PowerShell ISE of the VS Code integrated PowerShell terminal. The function will be deleted from the source file after it has been exported.
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.
Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/