Unframe

Convert-PubFileToPDF.ps1 is not recognized: how to run Microsoft’s script

PowerShell prints “not recognized” because it does not run a script from the current folder by name. Type .\Convert-PubFileToPDF.ps1, a dot and a backslash first, or give the full path. Microsoft’s own examples leave the .\ out. The script also needs a working, licensed Publisher on the same PC, and Windows blocks scripts by default until you allow them.

Last checked: October 28, 2026, against Microsoft's own pages and the sources listed at the end. Not affiliated with Microsoft.

The error, and why it appears

On July 29, 2026 a person with thousands of Publisher files wrote on Microsoft Q&A that Microsoft’s script “does not work”, with this error (thread):

The term ‘Convert-PubFileToPDF.ps1’ is not recognized as the name of a cmdlet, function, script file, or operable program.

One answer in the thread explains that PowerShell cannot find the script, because you are not in the folder that holds it or did not give its path. That matches Microsoft’s PowerShell documentation: “To run a script in the current directory, type the path to the current directory, or use a dot to represent the current directory, followed by a path backslash (.\)”, and PowerShell does not run a script “when you type the script name without a full path, even when the script is in the current directory” (about_Scripts (PowerShell 7.5)).

The examples on Microsoft’s retirement page show the script name with no .\ in front (Microsoft Publisher will no longer be supported after October 2026). Typed exactly as shown, from the folder that holds the script, PowerShell stops with the error above, as it did for the person in the thread.

Run it, step by step

  1. Check Publisher first. Microsoft’s first requirement is “a working and licensed version of Publisher installed on your computer”. Open one .pub file in it. If Save As and Export are greyed out, the script cannot help you: see Publisher Save As or Export greyed out.
  2. Put the files where you can find them. Download the sample script from Microsoft’s page and save it in a short folder such as C:\PubConvert. Copy the .pub files you want to convert to another folder, such as C:\PublisherFiles. Work on copies.
  3. Open PowerShell in the script’s folder. Open Windows PowerShell and type cd C:\PubConvert. To confirm that it can see the script, type Get-ChildItem Convert-PubFileToPDF.ps1: it should list the file.
  4. Allow scripts for this window only. Microsoft’s page says to open a PowerShell window “with the required execution policies”. On a Windows PC the default policy, Restricted, “doesn't allow scripts”. Type Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned to change it for this session only, then Unblock-File .\Convert-PubFileToPDF.ps1, because a downloaded unsigned script runs under RemoteSigned only once it is unblocked (about_Execution_Policies (Windows PowerShell 5.1)). The answers in the Q&A thread use -ExecutionPolicy Bypass instead, which is also session-only.
  5. Try one file. .\Convert-PubFileToPDF.ps1 -Filter "C:\PublisherFiles\one.pub"
  6. Then the folder. .\Convert-PubFileToPDF.ps1 -Filter "C:\PublisherFiles\*.pub" -Recurse. Microsoft says the script keeps going past errors and shows which files converted and which failed. It does not overwrite a PDF that already exists: delete or rename that one and run again.
  7. Check the PDFs. Open a few and compare every page with the .pub. Keep the originals.

Other places it stops

What you see, the usual cause, and what to do
What you seeThe usual causeWhat to do
“not recognized as the name of a cmdlet, function, script file”The script is not in the folder PowerShell is in, or the name was typed without .\ or a path.Use cd to its folder, check it with Get-ChildItem, and type .\ before the name, or the full path.
Scripts are blockedWindows computers default to the Restricted policy.Step 4: change the policy for this session only, and unblock the downloaded file.
Errors as soon as it starts convertingThe script drives Publisher through its automation interface. An answer in the thread says it fails when it cannot create the Publisher object, which is what happens when Publisher is not installed.Open Publisher yourself first. On a PC that has lost Publisher, use another PC with a perpetual Publisher, or one of the other routes below.
A file is skipped with an errorA PDF with the same name already exists.Delete or rename that PDF and run the script again.
Trouble with very long file names or wildcard charactersOne person in the July thread reported this and posted a modified script that converted 33,000 files.We have not tested that script. Read any script you did not write before you run it, and try it on copies.

No Publisher on this PC?

Then Microsoft’s script cannot run, and there are three ways to get the content. A PC with a perpetual Publisher can run the script; LibreOffice Draw opens .pub files, with a layout that can shift; and Unframe reads the file in your browser and gives back the text and pictures, with a folder mode that lists every .pub file and checks which ones it can read. The comparison is in PUB to PDF: every way to do it.

How many people are stuck on this

The question keeps coming back on Microsoft Q&A. On September 15 someone asked whether Microsoft had commands for converting .pub files to PDF in bulk (thread); on September 27 a person had more than 200 church programs (thread); and on October 25 a teacher with hundreds of files asked for help with the same job (thread). Microsoft calls the script a sample, “provided for instructional purposes”, and recommends modifying and testing it for your own needs.

Open a .pub file

Choose the file and get its text and pictures back, page by page, with a Word file to save. It runs in your browser and nothing is uploaded.

Questions

Do I need Publisher installed to run Convert-PubFileToPDF.ps1?

Yes. Microsoft’s page says to make sure you have a working and licensed version of Publisher installed on your computer, and an answer in the Microsoft Q&A thread says the script drives Publisher itself.

Why does PowerShell say the script is not recognized when it is in the same folder?

PowerShell does not run a script by name from the current folder. Microsoft’s PowerShell documentation says to use a dot and a backslash, as in .\Convert-PubFileToPDF.ps1, or the full path.

Will the script overwrite PDFs I already made?

No. Microsoft says that if the file name already exists, the script does not export the file and shows an error. Delete or rename the existing PDF and run it again.

Can I convert a .pub file to PDF without Publisher?

LibreOffice Draw can open .pub files and export a PDF, with a layout that can shift. Online converters upload your file. Unframe reads the file in your browser and gives back the text and pictures, not the layout.

Sources: Microsoft Support: Microsoft Publisher will no longer be supported after October 2026; Microsoft Learn: about_Scripts (PowerShell 7.5); Microsoft Learn: about_Execution_Policies (Windows PowerShell 5.1); Microsoft Q&A, July 29, 2026: Help Converting Publisher Files To PDFs; Microsoft Q&A, September 15, 2026: converting .pub to .pdf files in bulk?; Microsoft Q&A, September 27, 2026: How to convert in bulk over 200 church programs; Microsoft Q&A, October 25, 2026: How to mass convert Publisher files. Last checked: October 28, 2026. Unframe is an independent tool by Peak Apps Studio and is not affiliated with Microsoft. Microsoft and Publisher are trademarks of Microsoft Corporation.