Advertisement
Guest User

Untitled

a guest
Feb 24th, 2016
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. $Username = 'xxxx@xxx.com'
  2. $Password = ConvertTo-SecureString -AsPlainText 'xxxx' -Force
  3. $Livecred = New-Object System.Management.Automation.PSCredential $Username, $Password
  4. $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $Livecred -Authentication Basic -AllowRedirection
  5. INVOKE-COMMAND –Session $Session –scriptblock {Get-DistributionGroup}
  6.  
  7. PowerShell psExec = PowerShell.Create();
  8. Collection<PSObject> results;
  9. Collection<ErrorRecord> errors;
  10. psExec.AddScript(scriptText);
  11. results = psExec.Invoke();
  12. if (results != null && results.Count != 0){
  13. foreach (PSObject obj in results)
  14. {
  15. //this is where it retrieve the info from distribution group
  16. }
  17. }
  18.  
  19. PowerShell psExec = PowerShell.Create();
  20. Collection<PSObject> results;
  21. Collection<ErrorRecord> errors;
  22. psExec.AddScript(scriptText);
  23. results = psExec.Invoke();
  24. if (results != null && results.Count != 0){
  25. foreach (PSObject obj in results)
  26. {
  27. //this is where it retrieve the info from distribution group
  28. }
  29. }
  30.  
  31. Connecting to remote server outlook.office365.com failed with the following error message : Access is denied. For more information, see the about_Remote_Troubleshooting Help topic.rnCannot validate argument on parameter u0027Sessionu0027. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.rn"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement