How to: Get a list of mail users by using the Exchange Management Shell RRS feed

  • Question

  • Hello every one, quick question: When I run this code below for VB, how will I see the results of the program? Is there anyway I can make the results appear in a message box?

    Function GetUsersUsingBasicAuth( _
        ByVal LiveIDConnectionUri As String, ByVal ScehmaUri As String, _
        ByVal Credentials As PSCredential, ByVal Count As Integer) As Collection(Of PSObject)

        Dim ConnectionInfo As WSManConnectionInfo = _
            New WSManConnectionInfo(New Uri(LiveIDConnectionUri), ScehmaUri, Credentials)
        ConnectionInfo.AuthenticationMechanism = AuthenticationMechanism.Basic

        Dim RemoteRunspace As Runspace
        RemoteRunspace = RunspaceFactory.CreateRunspace(ConnectionInfo)

        Return GetUserInformation(Count, RemoteRunspace)

      End Function

    Function GetUserInformation(ByVal Count As Integer, ByVal RemoteRunspace As Runspace) As Collection(Of PSObject)

        Dim RemotePowerShell As PowerShell = PowerShell.Create
        RemotePowerShell.AddParameter("ResultSize", Count)

        ' Open the remote runspace on the server.

        ' Associate the runspace with the Exchange Management Shell.
        RemotePowerShell.Runspace = RemoteRunspace

        ' Invoke the Exchange Management Shell to run the command.
        Return RemotePowerShell.Invoke

    End Function

    Tuesday, July 1, 2014 3:09 PM

All replies