< Back

Export-Function

Sat Jan 18, 2020 6:47 pm

NAME Export-Function



SYNOPSIS

Exports a function from a module into a user given path





SYNTAX

Export-Function -Function <String> -OutPath <String> [<CommonParameters>]



Export-Function -Function <String> -ResolvedFunction <Object> -OutPath <String> [-PrivateFunction]

[<CommonParameters>]





DESCRIPTION

As synopsis





PARAMETERS

-Function <String>

This Parameter takes a String input and is used in Both Parameter Sets



Required? true

Position? named

Default value

Accept pipeline input? true (ByValue, ByPropertyName)

Accept wildcard characters? false



-ResolvedFunction <Object>

This should be passed the Function that you want to work with as an object making use of the following

$ResolvedFunction = Get-Command "Command"



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-OutPath <String>

This is the location that you want to output all the module files to. It is recommended not to use the same

location as where the module is installed.

Also always check the files output what you expect them to.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-PrivateFunction [<SwitchParameter>]

This is a switch that is used to correctly export Private Functions and is used internally in

Export-AllModuleFunction



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Export-Function -Function Get-TwitterTweet -OutPath C:\\TextFile\\



This will export the function into the C:\\TextFile\\Get\\Get-TwitterTweet.ps1 file and also create a basic test file

C:\\TextFile\\Get\\Get-TwitterTweet.Tests.ps1









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Get-Command -Module SPCSPS | Where-Object {$_.CommandType -eq 'Function'} | ForEach-Object {

Export-Function -Function $_.Name -OutPath C:\\TextFile\\SPCSPS\\ }



This will get all the Functions in the SPCSPS module (if it is loaded into memory or in a $env:PSModulePath as

required by ModuleAutoLoading) and will export all the Functions into the C:\\TextFile\\SPCSPS\\ folder under the

respective Function Verbs. It will also create a basic Tests.ps1 file just like the prior example











RELATED LINKS