I made a Powershell function just now and saved it to a ps1 file. However, when I try to execute it from within powershell, it won\'t run.
I\'ve allready changed to
If you replace "function listallpaths" with param and get rid of the surrounding {} like this..
param([string]$fromFolder, [string]$filter, [string]$printfile)
Get-ChildItem -Path $fromFolder -Include $filter -Recurse -Force -Name > $printfile
You will have a script file that you can call as required.
PS> .\listAllPaths.ps1 c:\ *.pdf testingPDF.txt
As Matt alluded to, by declaring the function, when you called the script, it would create the function and then exit. A PowerShell script is basically a function stored in a file (without the surrounding braces.. they are implied), where the function itself would be stored in memory.