Calling Exchange 2010 Cmdlets from a service RRS feed

  • Question

  • Hello,

    I am trying to build a web service that calls a powershell a script which then calls an exchange cmdlet. However, i am getting error messages that my ps script cannot find the cmdlet. 

    I have pasted below my .NET code to call the ps and my script.  Any thoughts on what i need to do differently or if you could point me to an example, I would appreciate it.


    .NET code in Web Service

    Runspace runspace = RunspaceFactory.CreateRunspace();
    // set variables to connect to script
                    runspace.SessionStateProxy.SetVariable("identity", identity);
                    runspace.SessionStateProxy.SetVariable("database", database);
    Powershell script
    Function New-ExchangeUser
    	) #end param
    	Enable-Mailbox -Identity $identity -Database $database
    } #end function
    New-ExchangeUser -identity $args[0]  -database $args[1]

    Wednesday, July 25, 2012 10:47 PM

All replies