RunspaceFactory.CreateRunspace() & Exchange Server 2010 RRS feed

  • Question

  • Hi, I'm in my first attempt in creating an aspx.vb script which accepts inputs from the front end and executes a powershell script. I have a couple of questions.

    1.The exchange powershell script requires input parameters prior to script execution e.g. “./check.ps1 –parameter1 [input] –parameter2 [input]"

    2.How do I close the Runspace session? / use the system.dbnull etc…

    ' Create a RunSpace to host the Powershell script environment using RunspaceFactory.CreateRunSpace.
    Dim runSpace As Runspace = RunspaceFactory.CreateRunspace()
    ' Create a Pipeline to host commands to be executed using Runspace.CreatePipeline.
    'Dim ID As String
    'Dim CSVPATH As String
    Dim q As Object = System.IO.Directory.GetCurrentDirectory().ToString
    Dim r As Object = TextBox1.Text
    Dim pipeLine As Pipeline = runSpace.CreatePipeline()
    ' Create a Command object by passing the command to the constructor.
    Dim PSTPSStarted As New Command("D:\Reports\Check.ps1")
    PSTPSStarted.Parameters.Add("ID", "r")
    PSTPSStarted.Parameters.Add("CSVPATH", "q")
    ' Add the commands to the Pipeline. 
    StatusLabel.Text = "Upload status:" & PSTPSStarted.ToString
    ' Run all commands in the current pipeline by calling Pipeline.Invoke
    ' dispose the pipeline
    'dispose the runspace

    Wednesday, April 23, 2014 8:59 AM

All replies