Advertisement
Guest User

Untitled

a guest
Feb 10th, 2014
246
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $username  = "username@tenancy.onmicrosoft.com"
  2. $password = "PASSWORDHERE"
  3. $secstr = New-Object -TypeName System.Security.SecureString
  4. $password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
  5. $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr
  6. try
  7. {
  8.     $msc = Connect-MsolService -Credential $cred -ErrorAction Stop
  9.     Write-Output "Connected. <br />"
  10. }
  11. catch
  12. {
  13.     Write-Output "Could not connect. <br />"
  14. }
Advertisement
RAW Paste Data Copied
Advertisement