Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.64 KB | None | 0 0
  1. [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
  2. Function Mirror_UserFun
  3. {
  4. param([string]$MU=$args[0])
  5. $MirrorUser = Get-ADUser -identity $MU -properties memberof | select memberof
  6. }
  7. Function Create_User
  8. {
  9. param()
  10. New-ADUser -SamAccountName $samaccountname -Name $displayname -Office $LC -ChangePasswordAtLogon $true -Title $JT -AccountPassword $password
  11. ForEach ($group in $MirrorUser)
  12. {
  13. Add-ADGroupMember $group -Members $samaccountname
  14. }
  15. }
  16. $textboxsize = New-Object System.Drawing.Size (85,8)
  17. $labelsize = New-Object System.Drawing.Size(65,15)
  18.  
  19. $NewStarterForm = New-Object System.Windows.Forms.Form
  20. $NewStarterForm.Text = "New Start Form"
  21. $NewStarterForm.Size = New-Object System.Drawing.Size(300,500)
  22. $NewStarterForm.FormBorderStyle = "FixedDialog"
  23. $NewStarterForm.TopMost = $true
  24. $NewStarterForm.MaximizeBox = $false
  25. $NewStarterForm.MinimizeBox = $false
  26. $NewStarterForm.ControlBox = $true
  27. $NewStarterForm.KeyPreview = $True
  28. $NewStarterForm.StartPosition = "CenterScreen"
  29. $NewStarterForm.Font = "Segoe UI"
  30.  
  31. #firstname Label
  32. $FirstName_NewStarterForm = New-Object System.Windows.Forms.Label
  33. $FirstName_NewStarterForm.Location = New-Object System.Drawing.Size(8,8)
  34. $FirstName_NewStarterForm.Size = $labelsize
  35. $FirstName_NewStarterForm.TextAlign = "TopLeft"
  36. $FirstName_NewStarterForm.Text = "First Name :"
  37. $NewStarterForm.Controls.Add($FirstName_NewStarterForm)
  38. #firstname textbox
  39. $firstname_textbox = New-Object System.Windows.Forms.TextBox
  40. $firstname_textbox.Location = New-Object System.Drawing.Size (85,8)
  41. $firstname_textbox.Size = $textboxsize
  42. $firstname_textbox.TextAlign = "Left"
  43. $firstname_textbox.Text
  44. $NewStarterForm.Controls.Add($firstname_textbox)
  45.  
  46. #Initial Label
  47. $Intial_NewStarterForm = New-Object System.Windows.Forms.Label
  48. $Intial_NewStarterForm.Location = New-Object System.Drawing.Size(175,40)
  49. $Intial_NewStarterForm.Size = New-Object System.Drawing.Size(25,32)
  50. $Intial_NewStarterForm.TextAlign = "TopLeft"
  51. $Intial_NewStarterForm.Text = "In:"
  52. $NewStarterForm.Controls.Add($Intial_NewStarterForm)
  53.  
  54. #Initial textbox
  55. $Intitial_textbox = New-Object System.Windows.Forms.TextBox
  56. $Intitial_textbox.Location = New-Object System.Drawing.Size (200,40)
  57. $Intitial_textbox.Size = $textboxsize
  58. $Intitial_textbox.TextAlign = "Left"
  59. $Intitial_textbox.Text
  60. $NewStarterForm.Controls.Add($Intitial_textbox)
  61.  
  62. #Surname Label
  63. $Surname_NewStarterForm = New-Object System.Windows.Forms.Label
  64. $Surname_NewStarterForm.Location = New-Object System.Drawing.Size(10,44)
  65. $Surname_NewStarterForm.Size = $labelsize
  66. $Surname_NewStarterForm.TextAlign = "MiddleLeft"
  67. $Surname_NewStarterForm.Text = "Surname:"
  68. $NewStarterForm.Controls.Add($Surname_NewStarterForm)
  69.  
  70. #Surname textbox
  71. $Surname_textbox = New-Object System.Windows.Forms.TextBox
  72. $Surname_textbox.Location = New-Object System.Drawing.Size (85,40)
  73. $Surname_textbox.Size = $textboxsize
  74. $Surname_textbox.TextAlign = "Left"
  75. $Surname_textbox.Text
  76. $NewStarterForm.Controls.Add($Surname_textbox)
  77.  
  78. #Location Label
  79. $Location_NewStarterForm = New-Object System.Windows.Forms.Label
  80. $Location_NewStarterForm.Location = New-Object System.Drawing.Size(10,75)
  81. $Location_NewStarterForm.Size = $labelsize
  82. $Location_NewStarterForm.TextAlign = "BottomLeft"
  83. $Location_NewStarterForm.Text = "Location:"
  84. $NewStarterForm.Controls.Add($Location_NewStarterForm)
  85.  
  86. #Location textbox
  87. $Location_textbox = New-Object System.Windows.Forms.TextBox
  88. $Location_textbox.Location = New-Object System.Drawing.Size (85,70)
  89. $Location_textbox.Size = $textboxsize
  90. $Location_textbox.TextAlign = "Left"
  91. $Location_textbox.Text
  92. $NewStarterForm.Controls.Add($Location_textbox)
  93.  
  94. #Job Title Label
  95. $JobTitle_NewStarterForm = New-Object System.Windows.Forms.Label
  96. $JobTitle_NewStarterForm.Location = New-Object System.Drawing.Size(10,105)
  97. $JobTitle_NewStarterForm.Size = $labelsize
  98. $JobTitle_NewStarterForm.TextAlign = "BottomLeft"
  99. $JobTitle_NewStarterForm.Text = "Job Title:"
  100. $NewStarterForm.Controls.Add($JobTitle_NewStarterForm)
  101.  
  102. #Job Title textbox
  103. $JobTitle_textbox = New-Object System.Windows.Forms.TextBox
  104. $JobTitle_textbox.Location = New-Object System.Drawing.Size (85,100)
  105. $JobTitle_textbox.Size = $textboxsize
  106. $JobTitle_textbox.TextAlign = "Left"
  107. $JobTitle_textbox.Text
  108. $NewStarterForm.Controls.Add($JobTitle_textbox)
  109.  
  110. #Mirror Label
  111. $MirrorUser_NewStarterForm = New-Object System.Windows.Forms.Label
  112. $MirrorUser_NewStarterForm.Location = New-Object System.Drawing.Size(10,180)
  113. $MirrorUser_NewStarterForm.Size = $labelsize
  114. $MirrorUser_NewStarterForm.TextAlign = "BottomLeft"
  115. $MirrorUser_NewStarterForm.Text = "Mirror User:"
  116. $NewStarterForm.Controls.Add($MirrorUser_NewStarterForm)
  117.  
  118. #Mirror textbox
  119. $MirrorUser_textbox = New-Object System.Windows.Forms.TextBox
  120. $MirrorUser_textbox.Location = New-Object System.Drawing.Size (85,175)
  121. $MirrorUser_textbox.Size = $textboxsize
  122. $MirrorUser_textbox.TextAlign = "Left"
  123. $MirrorUser_textbox.Text
  124. $NewStarterForm.Controls.Add($MirrorUser_textbox)
  125.  
  126. #Mirror User Button
  127. $MirrorUser_Button = New-Object System.Windows.Forms.Button
  128. $MirrorUser_Button.Location = New-Object System.Drawing.Size(180,175)
  129. $MirrorUser_Button.Size = New-Object System.Drawing.Size(80,20)
  130. $MirrorUser_Button.Text = "Get User"
  131. $MirrorUser_Button.add_click({Mirror_UserFun})
  132. $NewStarterForm.Controls.Add($MirrorUser_Button)
  133.  
  134.  
  135. #CreateUser Button
  136. ##$CreateUser_Button = New-Object System.Windows.Forms.Button
  137. ## $CreateUser_Button.Location = New-Object System.Drawing.Size(180,205)
  138. ## $CreateUser_Button.Size = New-Object System.Drawing.Size(80,20)
  139. ## $CreateUser_Button.Text = "Create User"
  140. ## $CreateUser_Button.DialogResult = ([System.Windows.Forms.DialogResult]::YES)
  141. ## $NewStarterForm.Controls.Add($CreateUser_Button)
  142. #HomeDrive Creation
  143.  
  144. #Return Results + show form
  145. $NewStarterForm.Add_Shown({$NewStarterForm.Activate()})
  146. $result = $NewStarterForm.ShowDialog()
  147. 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
  148.  
  149.  
  150.  
  151. ##$samaccountname = $SN + $IN
  152. ##$displayname = $FN + $SN
  153. ##$password = 'Thursday.1'
  154.  
  155. ##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