Advertisement
Guest User

Untitled

a guest
Aug 29th, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. Get-mailbox -resultsize unlimited
  2.  
  3. PSCredential credential = new PSCredential("Administrator", securePassword); // the password must be of type SecureString
  4. WSManConnectionInfo connectionInfo = new WSManConnectionInfo(connectTo,schemaURI, credential);
  5. connectionInfo.MaximumConnectionRedirectionCount = 5;
  6. connectionInfo.SkipCACheck = true;
  7. connectionInfo.SkipCNCheck = true;
  8.  
  9. try
  10. {
  11. Runspace remoteRunspace = RunspaceFactory.CreateRunspace(connectionInfo);
  12. remoteRunspace.Open();
  13. var command = new Command("Get-mailbox");
  14. command.Parameters.Add("resultsize", "unlimited");
  15. var pipeline = remoteRunspace.CreatePipeline();
  16. pipeline.Commands.Add(command);
  17. // Execute the command
  18. var results = pipeline.Invoke();
  19. MessageBox.Show(results.Count.ToString());
  20. remoteRunspace.Dispose();
  21. }
  22. catch (Exception ex)
  23. {
  24. //Handle error
  25. }
  26.  
  27. Get-mailbox | select-object DisplayName, PrimarySmtpAddress, ForwardingAddress, alias, identity, legacyexchangeDN | where-object {$_.ForwardingAddress -ne $Null}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement