The term ‘ ‘ is not recognized as the name of a cmdlet,

Question:

I have a PowerShell script stored in a file, MergeDocuments.ps1. When I run the script from the Windows PowerShell command prompt it runs fine
.\MergeDocuments.ps1 1.docx 2.docx merge.docx

Calling the script from a Windows console application also runs fine.

When I tried calling the script from an Asp.Net web service, I faced some issues regarding registry access. I used impersonation and gave permission to Network Service account to the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell to solve this problem

Next I faced issue about PowerShell being unable to create objects of type OpenXmlPowerTools.DocumentSource[], so I added the following to my script

Now the current problem is that I am getting the error “The term ‘Merge-OpenXmlDocument’ is not recognized as the name of a cmdlet, …”

How can I solve that?

PowerShell Script

Webservice .Net Code

Answer:

Can you just try to install OpenXmlPowerTools module in the PowerShell System module path :

Source:

The term ‘ ‘ is not recognized as the name of a cmdlet, by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply