EDN Admin
Well-known member
Hi,
It seems easy enough in theory but Im getting a constant error. Heres the code:
<pre class="prettyprint PSCommand importModule = new PSCommand();
importModule.AddCommand("Import-Module").AddParameter("Name", "ActiveDirectory");
powershell.AddCommand("import-module");
powershell.Commands = psCommand;
Collection<PSObject> results = new Collection<PSObject>();
try
{
powershell.Invoke();
}
catch (Exception ex)
{
results.Add(new PSObject((object)ex.Message));
}
[/code]
I write errors to a log file, and this is the message I get:
The term Import-Module 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.<br/>
Any Idea whats going on? Is there something I need to do before I try to import a module?
Thanks,
Rob
View the full article
It seems easy enough in theory but Im getting a constant error. Heres the code:
<pre class="prettyprint PSCommand importModule = new PSCommand();
importModule.AddCommand("Import-Module").AddParameter("Name", "ActiveDirectory");
powershell.AddCommand("import-module");
powershell.Commands = psCommand;
Collection<PSObject> results = new Collection<PSObject>();
try
{
powershell.Invoke();
}
catch (Exception ex)
{
results.Add(new PSObject((object)ex.Message));
}
[/code]
I write errors to a log file, and this is the message I get:
The term Import-Module 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.<br/>
Any Idea whats going on? Is there something I need to do before I try to import a module?
Thanks,
Rob
View the full article