Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Get-mailbox -resultsize unlimited
- PSCredential credential = new PSCredential("Administrator", securePassword); // the password must be of type SecureString
- WSManConnectionInfo connectionInfo = new WSManConnectionInfo(connectTo,schemaURI, credential);
- connectionInfo.MaximumConnectionRedirectionCount = 5;
- connectionInfo.SkipCACheck = true;
- connectionInfo.SkipCNCheck = true;
- try
- {
- Runspace remoteRunspace = RunspaceFactory.CreateRunspace(connectionInfo);
- remoteRunspace.Open();
- var command = new Command("Get-mailbox");
- command.Parameters.Add("resultsize", "unlimited");
- var pipeline = remoteRunspace.CreatePipeline();
- pipeline.Commands.Add(command);
- // Execute the command
- var results = pipeline.Invoke();
- MessageBox.Show(results.Count.ToString());
- remoteRunspace.Dispose();
- }
- catch (Exception ex)
- {
- //Handle error
- }
- 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