title: Calling Get-MsolUser returns no results
body: <p>I'm working on the some proof of concept code for a system that will manage a large number of Office365 accounts, however, I seem to be struggling at the first hurdle with a rather daft problem.</p>
  
  <p>I'm using the RunspaceFactory to fire my Powershell commands at Office 365 and whilst the code appears to be running without any errors I never get a list of users back.</p>
  
  <p>Firstly here's my code....</p>
  
  <pre><code>Runspace runSpace = RunspaceFactory.CreateRunspace();
  runSpace.Open();
  
  Pipeline pipeline = runSpace.CreatePipeline();
  
  Command msolConnect = new Command("Connect-MsolService");
  
  System.Security.SecureString securePassword = new System.Security.SecureString();
  foreach (char pwdLetter in password)
  {
      securePassword.AppendChar(pwdLetter);
  }
  PSCredential credential = new PSCredential(username, securePassword);
  msolConnect.Parameters.Add("Credential", credential);
  pipeline.Commands.Add(msolConnect);
  
  Command msolGetUser = new Command("Get-MsolUser");
  msolGetUser.Parameters.Add("SearchString", "hayley");
  pipeline.Commands.Add(msolGetUser);
  
  
  Collection&lt;PSObject&gt; connectOutput = pipeline.Invoke();
  foreach (PSObject psObject in connectOutput)
  {
      Console.WriteLine(psObject.Members["DisplayName"].Value.ToString());
  }
  </code></pre>
  
  <p>The pipline.HadErrors is false and the connectOutput is always empty.  It appears that code is succesfully running but without returning any results.</p>
  
  <p>I have tried;</p>
  
  <ul>
  <li>the same command in Windows Powershell and I get back a list of expected results.</li>
  <li>mis-spelling SearchString (just to check that the command was running and the parameter was being passed) and an error is generated as I would expect I have also</li>
  <li>using ImportPSModule(new[] { "MsOnline" }) to ensure the MSOnline module is available</li>
  <li>other commands (e.g. Get-MsolGroup) and get back an empty list</li>
  </ul>
  
  <p>I know find myself scratching my head on a Friday afternoon hoping that someone else may be able to help me...</p>
  
  <p>Thanks in advance,</p>
  
  <p>Darren</p>