A desktop publishing application from Microsoft that focuses on page layout and graphic design.
That error is occurring before the script runs. PowerShell cannot find Convert-PubFileToPDF.ps1 in your current directory.
First, check where PowerShell is currently looking:
Get-Location
Then check whether the script is actually in that folder:
Test-Path .\Convert-PubFileToPDF.ps1
If that returns False, change to the folder containing the script. For example, if you saved it in C:\Scripts:
Set-Location C:\Scripts
Then verify:
Test-Path .\Convert-PubFileToPDF.ps1
It should return True. You can then run:
.\Convert-PubFileToPDF.ps1 -Filter "C:\PublisherFiles*.pub" -Recurse
Alternatively, specify the complete path to the script without changing directories:
C:\Scripts\Convert-PubFileToPDF.ps1 -Filter "C:\PublisherFiles*.pub" -Recurse
If the script is downloaded from the Internet and Windows has blocked it, you may also need:
Unblock-File C:\Scripts\Convert-PubFileToPDF.ps1
Then run it again.
One other possibility is that the file was saved with a different extension, such as Convert-PubFileToPDF.ps1.txt. Check with:
Get-ChildItem C:\Scripts\Convert-PubFileToPDF*
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin