Created
July 23, 2020 11:00
-
-
Save gscales/7c3b82cec8059797b81b917bd45bcfa8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
System.Security.SecureString secureString = new System.Security.SecureString(); | |
string myPassword = "password"; | |
foreach (char c in myPassword) | |
secureString.AppendChar(c); | |
PSCredential credential = new PSCredential("glen@domain.com", secureString); | |
WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri("https://ps.outlook.com/PowerShell-LiveID?PSVersion=2.0"), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential); | |
connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Basic; | |
connectionInfo.SkipCACheck = true; | |
connectionInfo.SkipCNCheck = true; | |
connectionInfo.MaximumConnectionRedirectionCount = 4; | |
Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(connectionInfo); | |
runspace.Open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment