We are using the Powershell object to retrieve the GetMailbox from Exchange Server 2013 and we got the result but we want to retrieve all properties i.e in Format List or Format Table. I can't able to do this.
Here is the Code. Thanks in advance.
 public Collection<PSObject> GetUsersUsingBasicAuth(string liveIDConnectionUri, string schemaUri, PSCredential credentials, int count)
    {
      WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri(liveIDConnectionUri), schemaUri, credentials);
      connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Basic;
    Â
      using (Runspace runspace = RunspaceFactory.CreateRunspace(connectionInfo))
      {
       Â
        strCommand = "Get-mailbox";
        count = 100;
        return GetUserInformation(count, runspace, strCommand);
      }
    }
 public Collection<PSObject> GetUserInformation(int count, Runspace runspace, string commands)
    {
      using (PowerShell powershell = PowerShell.Create())
      {
        // powershell.AddScript(commands);
        powershell.AddCommand(commands);
        powershell.AddParameter("ResultSize", count);
        powershell.AddParameter("Filter", "Displayname -like 'Testuser'");
      Â
        runspace.Open();
        powershell.Runspace = runspace;
        return powershell.Invoke();
      }
    }
    protected void ExecuteCommand_Click(object sender, EventArgs e)
    {
     Â
      string user, pass;
      user = Session["Username"].ToString();
      pass = Session["Password"].ToString();
      var secure = new SecureString();
      string password = pass;
      foreach (char c in password)
      {
        secure.AppendChar(c);
      }
      Â
      PSCredential obj = new PSCredential(user, secure);
      Collection<PSObject> results = GetUsersUsingBasicAuth(SHELL_URI, "http://schemas.microsoft.com/powershell/Microsoft.Exchange", obj, 15);
      result = new List<string>();
      for (int i = 0; i < results.Count; i++)
      {
        result.Add(results[i].ToString());
      }
      Â
      gv.DataSource = result;
      gv.DataBind();
      Â
      Â
    }