The code below runs greate in VB.Net 2008 (.Net 2.0) but when I execute it in IIS6 or IIS7 it doesn't return any data. For some reason it doesn't enter the 'next' loop. The interesting thing is that if I substitute "get-mailboxstatistics" with "get-mailbox" that works in both the compiler and in IIS7&6.
any ideas?
-------------
Sub GetMailboxData()
Dim exReturn As String = Nothing
Dim rsConfig As RunspaceConfiguration = RunspaceConfiguration.Create()
Dim snapInException As PSSnapInException = Nothing
Dim info As PSSnapInInfo = rsConfig.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", snapInException)
Dim myRunSpace As Runspace = RunspaceFactory.CreateRunspace(rsConfig)
myRunSpace.Open()
Dim ri As New RunspaceInvoke(myRunSpace)
Dim errors As IList
Dim commandResults As ICollection(Of PSObject)
commandResults = ri.Invoke(
"get-mailboxstatistics -server exch01", Nothing, errors)
Dim ResultString As New StringBuilder
For Each cmdlet As PSObject In commandResults
exReturn = cmdlet.Properties(
"DisplayName").Value
exReturn = exReturn &
" " & cmdlet.Properties("ServerName").Value
ResultString.Append(exReturn & vbNewLine)
Next
TextBox1.Text = (ResultString.ToString)
End Sub
--------------