EDN Admin
Well-known member
My Dev Server is Windows Server R2 SP1 and Exchange 2010 SP2, Visual Studio 2010.
I an writing a C# application that runs Exchange PowerShell commends. When I execute this code
<span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small
static void Main(string[] args)<br/>
{<br/>
RunPowershellScript(@"Crogram FilesMicrosoftExchange ServerV14binRemoteExchange.ps1", "Get-Mailbox -identity administrator");
<br/>
}<br/>
private static void RunPowershellScript(string scriptFile, string scriptParameters)<br/>
{<br/>
RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create();<br/>
Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConfiguration);<br/>
runspace.Open();<br/>
RunspaceInvoke scriptInvoker = new RunspaceInvoke(runspace);<br/>
Pipeline pipeline = runspace.CreatePipeline();<br/>
Command scriptCommand = new Command(scriptFile);<br/>
Collection<CommandParameter> commandParameters = new Collection<CommandParameter>();<br/>
foreach (string scriptParameter in scriptParameters.Split( ))<br/>
{<br/>
CommandParameter commandParm = new CommandParameter(null, scriptParameter);<br/>
commandParameters.Add(commandParm);<br/>
scriptCommand.Parameters.Add(commandParm);<br/>
}<br/>
pipeline.Commands.Add(scriptCommand);<br/>
Collection<PSObject> psObjects;<br/>
psObjects = pipeline.Invoke();<br/>
Console.Write(psObjects);<br/>
}<br/>
}
I get the following Error:
The term binCommonConnectFunctions.ps1 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.
Thanks
<span style="font-size:small
<span style="font-size:small
<span style="font-size:small
<
HD
<br/>
<br/>
View the full article
I an writing a C# application that runs Exchange PowerShell commends. When I execute this code
<span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small
static void Main(string[] args)<br/>
{<br/>
RunPowershellScript(@"Crogram FilesMicrosoftExchange ServerV14binRemoteExchange.ps1", "Get-Mailbox -identity administrator");
<br/>
}<br/>
private static void RunPowershellScript(string scriptFile, string scriptParameters)<br/>
{<br/>
RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create();<br/>
Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConfiguration);<br/>
runspace.Open();<br/>
RunspaceInvoke scriptInvoker = new RunspaceInvoke(runspace);<br/>
Pipeline pipeline = runspace.CreatePipeline();<br/>
Command scriptCommand = new Command(scriptFile);<br/>
Collection<CommandParameter> commandParameters = new Collection<CommandParameter>();<br/>
foreach (string scriptParameter in scriptParameters.Split( ))<br/>
{<br/>
CommandParameter commandParm = new CommandParameter(null, scriptParameter);<br/>
commandParameters.Add(commandParm);<br/>
scriptCommand.Parameters.Add(commandParm);<br/>
}<br/>
pipeline.Commands.Add(scriptCommand);<br/>
Collection<PSObject> psObjects;<br/>
psObjects = pipeline.Invoke();<br/>
Console.Write(psObjects);<br/>
}<br/>
}
I get the following Error:
The term binCommonConnectFunctions.ps1 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.
Thanks
<span style="font-size:small
<span style="font-size:small
<span style="font-size:small
<
HD
<br/>
<br/>
View the full article