Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Export powershell function

$
0
0

Hi,

I wrote several functions in powershell(diff versions) on my day to day tasks. I have a general question. I write a function like,

Function Test-function {

.....

...

and save it as test.ps1.Now when I run this script in powershell console as test.ps1, that function test-function will be called at the script start and ends at script end. Now at the console, if I enter test-function, it says no function available. Now to use this function, I need to use dot sourcing like, . .\test.ps1. Do we have any other way where I can use this function without dot sourcing? As I have to use it as . .\test.ps1, I am converting all my scripts to modules and then importing them. Do we have any way other than dot sourcing and converting to modules whereI can directly execute the script and use the function?

Chaitanya.


Viewing all articles
Browse latest Browse all 6937

Trending Articles