Wednesday, 18 September 2013

Use custom powershell module in C#

Use custom powershell module in C#

I wrote fuction PowerShell module like that:
Function docConvert2{
param ([string]$sourceFile, [string]$sourceFilePath)
....
....
}
I've imported module successfuly

And i can use module in powershell cmdlet

When i try call function in c#, i got exception like that
The term 'docConvert2' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try
again.
C# code
PowerShell pShell = PowerShell.Create();
pShell.AddCommand("docConvert2");
pShell.AddParameter("sourceFile", "'addendum no-3_PREP.doc'");
pShell.AddParameter("sourceFilePath", @"'D:\New\wordler'");
pShell.Invoke();
What is my mistake?
Thanks for advices.

No comments:

Post a Comment