Powershell ps1 file “is not recognized as a cmdlet, function, operable program, or script file.”

http://stackoverflow.com/questions/762927/powershell-ps1-file-is-not-recognized-as-a-cmdlet-function-operable-program

This is a typical error across many platforms where your environment path does not include your current directory. so when you execute your script (or command or program etc), your runtime environment looks everywhere except your current/working directory.

Try

PS> .\listAllPaths.ps1 c:\ *.pdf testingPDF.txt

EDIT: After reading your comments, I’m going to suggest you try this. I haven’t actually verified the logic of your PS script. I’m merely trying to get your script to execute first.

Try editing your script as below, and execute as above.

Function listAllPaths([string]$fromFolder, [string]$filter, [string]$printfile){
Get-ChildItem -Path $fromFolder -Include $filter -Recurse -Force -Name > $printfile
}

listAllPaths
shareedit
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s