Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
- Function Mirror_UserFun
- {
- param([string]$MU=$args[0])
- $MirrorUser = Get-ADUser -identity $MU -properties memberof | select memberof
- }
- Function Create_User
- {
- param()
- New-ADUser -SamAccountName $samaccountname -Name $displayname -Office $LC -ChangePasswordAtLogon $true -Title $JT -AccountPassword $password
- ForEach ($group in $MirrorUser)
- {
- Add-ADGroupMember $group -Members $samaccountname
- }
- }
- $textboxsize = New-Object System.Drawing.Size (85,8)
- $labelsize = New-Object System.Drawing.Size(65,15)
- $NewStarterForm = New-Object System.Windows.Forms.Form
- $NewStarterForm.Text = "New Start Form"
- $NewStarterForm.Size = New-Object System.Drawing.Size(300,500)
- $NewStarterForm.FormBorderStyle = "FixedDialog"
- $NewStarterForm.TopMost = $true
- $NewStarterForm.MaximizeBox = $false
- $NewStarterForm.MinimizeBox = $false
- $NewStarterForm.ControlBox = $true
- $NewStarterForm.KeyPreview = $True
- $NewStarterForm.StartPosition = "CenterScreen"
- $NewStarterForm.Font = "Segoe UI"
- #firstname Label
- $FirstName_NewStarterForm = New-Object System.Windows.Forms.Label
- $FirstName_NewStarterForm.Location = New-Object System.Drawing.Size(8,8)
- $FirstName_NewStarterForm.Size = $labelsize
- $FirstName_NewStarterForm.TextAlign = "TopLeft"
- $FirstName_NewStarterForm.Text = "First Name :"
- $NewStarterForm.Controls.Add($FirstName_NewStarterForm)
- #firstname textbox
- $firstname_textbox = New-Object System.Windows.Forms.TextBox
- $firstname_textbox.Location = New-Object System.Drawing.Size (85,8)
- $firstname_textbox.Size = $textboxsize
- $firstname_textbox.TextAlign = "Left"
- $firstname_textbox.Text
- $NewStarterForm.Controls.Add($firstname_textbox)
- #Initial Label
- $Intial_NewStarterForm = New-Object System.Windows.Forms.Label
- $Intial_NewStarterForm.Location = New-Object System.Drawing.Size(175,40)
- $Intial_NewStarterForm.Size = New-Object System.Drawing.Size(25,32)
- $Intial_NewStarterForm.TextAlign = "TopLeft"
- $Intial_NewStarterForm.Text = "In:"
- $NewStarterForm.Controls.Add($Intial_NewStarterForm)
- #Initial textbox
- $Intitial_textbox = New-Object System.Windows.Forms.TextBox
- $Intitial_textbox.Location = New-Object System.Drawing.Size (200,40)
- $Intitial_textbox.Size = $textboxsize
- $Intitial_textbox.TextAlign = "Left"
- $Intitial_textbox.Text
- $NewStarterForm.Controls.Add($Intitial_textbox)
- #Surname Label
- $Surname_NewStarterForm = New-Object System.Windows.Forms.Label
- $Surname_NewStarterForm.Location = New-Object System.Drawing.Size(10,44)
- $Surname_NewStarterForm.Size = $labelsize
- $Surname_NewStarterForm.TextAlign = "MiddleLeft"
- $Surname_NewStarterForm.Text = "Surname:"
- $NewStarterForm.Controls.Add($Surname_NewStarterForm)
- #Surname textbox
- $Surname_textbox = New-Object System.Windows.Forms.TextBox
- $Surname_textbox.Location = New-Object System.Drawing.Size (85,40)
- $Surname_textbox.Size = $textboxsize
- $Surname_textbox.TextAlign = "Left"
- $Surname_textbox.Text
- $NewStarterForm.Controls.Add($Surname_textbox)
- #Location Label
- $Location_NewStarterForm = New-Object System.Windows.Forms.Label
- $Location_NewStarterForm.Location = New-Object System.Drawing.Size(10,75)
- $Location_NewStarterForm.Size = $labelsize
- $Location_NewStarterForm.TextAlign = "BottomLeft"
- $Location_NewStarterForm.Text = "Location:"
- $NewStarterForm.Controls.Add($Location_NewStarterForm)
- #Location textbox
- $Location_textbox = New-Object System.Windows.Forms.TextBox
- $Location_textbox.Location = New-Object System.Drawing.Size (85,70)
- $Location_textbox.Size = $textboxsize
- $Location_textbox.TextAlign = "Left"
- $Location_textbox.Text
- $NewStarterForm.Controls.Add($Location_textbox)
- #Job Title Label
- $JobTitle_NewStarterForm = New-Object System.Windows.Forms.Label
- $JobTitle_NewStarterForm.Location = New-Object System.Drawing.Size(10,105)
- $JobTitle_NewStarterForm.Size = $labelsize
- $JobTitle_NewStarterForm.TextAlign = "BottomLeft"
- $JobTitle_NewStarterForm.Text = "Job Title:"
- $NewStarterForm.Controls.Add($JobTitle_NewStarterForm)
- #Job Title textbox
- $JobTitle_textbox = New-Object System.Windows.Forms.TextBox
- $JobTitle_textbox.Location = New-Object System.Drawing.Size (85,100)
- $JobTitle_textbox.Size = $textboxsize
- $JobTitle_textbox.TextAlign = "Left"
- $JobTitle_textbox.Text
- $NewStarterForm.Controls.Add($JobTitle_textbox)
- #Mirror Label
- $MirrorUser_NewStarterForm = New-Object System.Windows.Forms.Label
- $MirrorUser_NewStarterForm.Location = New-Object System.Drawing.Size(10,180)
- $MirrorUser_NewStarterForm.Size = $labelsize
- $MirrorUser_NewStarterForm.TextAlign = "BottomLeft"
- $MirrorUser_NewStarterForm.Text = "Mirror User:"
- $NewStarterForm.Controls.Add($MirrorUser_NewStarterForm)
- #Mirror textbox
- $MirrorUser_textbox = New-Object System.Windows.Forms.TextBox
- $MirrorUser_textbox.Location = New-Object System.Drawing.Size (85,175)
- $MirrorUser_textbox.Size = $textboxsize
- $MirrorUser_textbox.TextAlign = "Left"
- $MirrorUser_textbox.Text
- $NewStarterForm.Controls.Add($MirrorUser_textbox)
- #Mirror User Button
- $MirrorUser_Button = New-Object System.Windows.Forms.Button
- $MirrorUser_Button.Location = New-Object System.Drawing.Size(180,175)
- $MirrorUser_Button.Size = New-Object System.Drawing.Size(80,20)
- $MirrorUser_Button.Text = "Get User"
- $MirrorUser_Button.add_click({Mirror_UserFun})
- $NewStarterForm.Controls.Add($MirrorUser_Button)
- #CreateUser Button
- ##$CreateUser_Button = New-Object System.Windows.Forms.Button
- ## $CreateUser_Button.Location = New-Object System.Drawing.Size(180,205)
- ## $CreateUser_Button.Size = New-Object System.Drawing.Size(80,20)
- ## $CreateUser_Button.Text = "Create User"
- ## $CreateUser_Button.DialogResult = ([System.Windows.Forms.DialogResult]::YES)
- ## $NewStarterForm.Controls.Add($CreateUser_Button)
- #HomeDrive Creation
- #Return Results + show form
- $NewStarterForm.Add_Shown({$NewStarterForm.Activate()})
- $result = $NewStarterForm.ShowDialog()
- return $mu = $mirroruser_textbox.Text, $FN = $firstname_textbox.Text, $SN = $Surname_textbox.Text, $IN = $Intitial_textbox.text, $LC = $Location_textbox.Text, $JT = $JobTitle_textbox.Text
- ##$samaccountname = $SN + $IN
- ##$displayname = $FN + $SN
- ##$password = 'Thursday.1'
- ##Get-MailboxDatabase -Status | sort name | select name,@{Name='DB Size (Gb)';Expression={$_.DatabaseSize.ToGb()}},@{Name='Available New Mbx Space Gb)';Expression={$_.AvailableNewMailboxSpace.ToGb()}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement