Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
762
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <# This form was created using POSHGUI.com  a free online gui designer for PowerShell
  2. .NAME
  3.     Untitled
  4. #>
  5.  
  6. Add-Type -AssemblyName System.Windows.Forms
  7. [System.Windows.Forms.Application]::EnableVisualStyles()
  8.  
  9. #region begin GUI{
  10.  
  11. $Form                            = New-Object system.Windows.Forms.Form
  12. $Form.ClientSize                 = '400,200'
  13. $Form.text                       = "5i Business - Office 365 Login"
  14. $Form.TopMost                    = $false
  15.  
  16. $Label1                          = New-Object system.Windows.Forms.Label
  17. $Label1.text                     = "Office 365 Login"
  18. $Label1.AutoSize                 = $true
  19. $Label1.width                    = 25
  20. $Label1.height                   = 10
  21. $Label1.location                 = New-Object System.Drawing.Point(126,35)
  22. $Label1.Font                     = 'Microsoft Sans Serif,14,style=Bold'
  23.  
  24. $Label2                          = New-Object system.Windows.Forms.Label
  25. $Label2.text                     = "Username"
  26. $Label2.AutoSize                 = $true
  27. $Label2.width                    = 25
  28. $Label2.height                   = 10
  29. $Label2.location                 = New-Object System.Drawing.Point(80,76)
  30. $Label2.Font                     = 'Microsoft Sans Serif,10'
  31.  
  32. $Label3                          = New-Object system.Windows.Forms.Label
  33. $Label3.text                     = "Password"
  34. $Label3.AutoSize                 = $true
  35. $Label3.width                    = 25
  36. $Label3.height                   = 10
  37. $Label3.location                 = New-Object System.Drawing.Point(82,113)
  38. $Label3.Font                     = 'Microsoft Sans Serif,10'
  39.  
  40. $TextBox1                        = New-Object system.Windows.Forms.TextBox
  41. $TextBox1.multiline              = $false
  42. $TextBox1.width                  = 150
  43. $TextBox1.height                 = 20
  44. $TextBox1.location               = New-Object System.Drawing.Point(156,74)
  45. $TextBox1.Font                   = 'Microsoft Sans Serif,10'
  46.  
  47. $MaskedTextBox1                  = New-Object system.Windows.Forms.MaskedTextBox
  48. $MaskedTextBox1.multiline        = $false
  49. $MaskedTextBox1.width            = 150
  50. $MaskedTextBox1.height           = 20
  51. $MaskedTextBox1.location         = New-Object System.Drawing.Point(156,109)
  52. $MaskedTextBox1.Font             = 'Microsoft Sans Serif,10'
  53.  
  54. $Button1                         = New-Object system.Windows.Forms.Button
  55. $Button1.text                    = "Login!"
  56. $Button1.width                   = 60
  57. $Button1.height                  = 30
  58. $Button1.location                = New-Object System.Drawing.Point(164,151)
  59. $Button1.Font                    = 'Microsoft Sans Serif,10,style=Bold'
  60.  
  61. $Form.controls.AddRange(@($Label1,$Label2,$Label3,$TextBox1,$MaskedTextBox1,$Button1))
  62.  
  63. $Button1.Add_Click({ Login-365 })
  64.  
  65. #endregion GUI }
  66.  
  67. #Write your logic code here
  68. Function Login-365 {
  69.  
  70. $username = $textbox1
  71. $password = $maskedtextbox1
  72.  
  73.  
  74.  
  75.                 $O365Session = New-PSSession -ConfigurationName Microsoft.Exchange  `
  76.                                             -ConnectionUri https://ps.outlook.com/powershell  `
  77.                                             -Credential $O365Cred -Authentication Basic  `
  78.                                             -AllowRedirection  `
  79.        
  80.         Connect-AzureAD -Credential $O365Cred
  81.         Connect-MsolService -Credential $O365Cred
  82.  
  83.             Import-Module MSOnline
  84.             Import-PSSession $O365Session
  85.        
  86.         Get-MsolDomain
  87.  
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement