Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <# This form was created using POSHGUI.com a free online gui designer for PowerShell
- .NAME
- Untitled
- #>
- Add-Type -AssemblyName System.Windows.Forms
- [System.Windows.Forms.Application]::EnableVisualStyles()
- #region begin GUI{
- $Form = New-Object system.Windows.Forms.Form
- $Form.ClientSize = '400,200'
- $Form.text = "5i Business - Office 365 Login"
- $Form.TopMost = $false
- $Label1 = New-Object system.Windows.Forms.Label
- $Label1.text = "Office 365 Login"
- $Label1.AutoSize = $true
- $Label1.width = 25
- $Label1.height = 10
- $Label1.location = New-Object System.Drawing.Point(126,35)
- $Label1.Font = 'Microsoft Sans Serif,14,style=Bold'
- $Label2 = New-Object system.Windows.Forms.Label
- $Label2.text = "Username"
- $Label2.AutoSize = $true
- $Label2.width = 25
- $Label2.height = 10
- $Label2.location = New-Object System.Drawing.Point(80,76)
- $Label2.Font = 'Microsoft Sans Serif,10'
- $Label3 = New-Object system.Windows.Forms.Label
- $Label3.text = "Password"
- $Label3.AutoSize = $true
- $Label3.width = 25
- $Label3.height = 10
- $Label3.location = New-Object System.Drawing.Point(82,113)
- $Label3.Font = 'Microsoft Sans Serif,10'
- $TextBox1 = New-Object system.Windows.Forms.TextBox
- $TextBox1.multiline = $false
- $TextBox1.width = 150
- $TextBox1.height = 20
- $TextBox1.location = New-Object System.Drawing.Point(156,74)
- $TextBox1.Font = 'Microsoft Sans Serif,10'
- $MaskedTextBox1 = New-Object system.Windows.Forms.MaskedTextBox
- $MaskedTextBox1.multiline = $false
- $MaskedTextBox1.width = 150
- $MaskedTextBox1.height = 20
- $MaskedTextBox1.location = New-Object System.Drawing.Point(156,109)
- $MaskedTextBox1.Font = 'Microsoft Sans Serif,10'
- $Button1 = New-Object system.Windows.Forms.Button
- $Button1.text = "Login!"
- $Button1.width = 60
- $Button1.height = 30
- $Button1.location = New-Object System.Drawing.Point(164,151)
- $Button1.Font = 'Microsoft Sans Serif,10,style=Bold'
- $Form.controls.AddRange(@($Label1,$Label2,$Label3,$TextBox1,$MaskedTextBox1,$Button1))
- $Button1.Add_Click({ Login-365 })
- #endregion GUI }
- #Write your logic code here
- Function Login-365 {
- $username = $textbox1
- $password = $maskedtextbox1
- $O365Session = New-PSSession -ConfigurationName Microsoft.Exchange `
- -ConnectionUri https://ps.outlook.com/powershell `
- -Credential $O365Cred -Authentication Basic `
- -AllowRedirection `
- Connect-AzureAD -Credential $O365Cred
- Connect-MsolService -Credential $O365Cred
- Import-Module MSOnline
- Import-PSSession $O365Session
- Get-MsolDomain
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement