Guest User

usercopyscript

a guest
Apr 9th, 2014
337
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Generated Form Function
  2. function GenerateForm {
  3. ########################################################################
  4. # Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.10.0
  5. # Generated On: 2014-02-13 11:34
  6. # Generated By: Jean-Sebastien Elie
  7. Import-Module ActiveDirectory
  8. Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
  9. ########################################################################
  10.  
  11. #region Import the Assemblies
  12. [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
  13. [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
  14. #endregion
  15.  
  16. #region Generated Form Objects
  17. $form1 = New-Object System.Windows.Forms.Form
  18. $lmanager = New-Object System.Windows.Forms.Label
  19. $cmbmgr = New-Object System.Windows.Forms.ComboBox
  20. $val5 = New-Object System.Windows.Forms.Label
  21. $pictureBox1 = New-Object System.Windows.Forms.PictureBox
  22. $pgbar = New-Object System.Windows.Forms.ProgressBar
  23. $infodisplay = New-Object System.Windows.Forms.Label
  24. $tuser = New-Object System.Windows.Forms.ComboBox
  25. $clear = New-Object System.Windows.Forms.Button
  26. $val4 = New-Object System.Windows.Forms.Label
  27. $val3 = New-Object System.Windows.Forms.Label
  28. $mailboxlist = New-Object System.Windows.Forms.ListBox
  29. $bcopy = New-Object System.Windows.Forms.Button
  30. $val2 = New-Object System.Windows.Forms.Label
  31. $val1 = New-Object System.Windows.Forms.Label
  32. $bvalidate = New-Object System.Windows.Forms.Button
  33. $label4 = New-Object System.Windows.Forms.Label
  34. $label3 = New-Object System.Windows.Forms.Label
  35. $label2 = New-Object System.Windows.Forms.Label
  36. $label1 = New-Object System.Windows.Forms.Label
  37. $tlname = New-Object System.Windows.Forms.TextBox
  38. $tfname = New-Object System.Windows.Forms.TextBox
  39. $tnewuser = New-Object System.Windows.Forms.TextBox
  40. $InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
  41. #endregion Generated Form Objects
  42.  
  43. #----------------------------------------------
  44. #Generated Event Script Blocks
  45. #----------------------------------------------
  46. #Provide Custom Code for events specified in PrimalForms.
  47.  
  48. $form1.FormBorderStyle = "FixedToolWindow"
  49.  
  50.  
  51. #ComboBox Ad user generation
  52. $arrac = get-aduser -SearchBase "OU=<YOUROU>,DC=<YOURCOMPANY>,DC=com" -Filter * | Sort-Object
  53.  
  54.  
  55. foreach($muser in $arrac)
  56.                 {
  57.                     $tuser.items.add($muser.Name)
  58.                     $cmbmgr.items.add($muser.Name)
  59.                                         }
  60.  
  61.  
  62. #Hutchinson Logo
  63.  
  64. # $picturebox1.imagelocation = "<Company logo path>"
  65. # $picturebox1.sizemode = "StretchImage"
  66.  
  67. #Mailbox Storage Group Listing
  68.  
  69. $mailboxlist.items.add("<YOURCOMPANY> MBX DB1")
  70. $mailboxlist.items.add("<YOURCOMPANY> MBX DB2")
  71. #$mailboxlist.items.add("Mailbox ThirdStorage Group")
  72.  
  73. # Global Var
  74. [string]$global:name = $null
  75. [string]$global:nameok = $null
  76. [string]$global:Newuser = $null
  77. [string]$global:fname = $null
  78. [string]$global:lname = $null
  79. [string]$global:nameds = $null
  80. [string]$global:NewUserds = $null
  81. [string]$global:db = $null
  82. [string]$global:mgr = $null
  83. [Int]$global:count = $null
  84. [string]$global:DN = $null
  85. [string]$global:OldUser = $null
  86. [string]$global:Parent = $null
  87. [string]$global:OU = $null
  88. [string]$global:OUDN = $null
  89. [string]$global:domain = $null
  90. [Int]$global:countr = $null
  91. [Int]$global:index = $null
  92. [string]$global:iuser = $null
  93. [Int]$global:index2 = $null
  94.  
  95. $bcopy_OnClick=
  96. {
  97. $clear.visible = $False
  98. $pgbar.visible = $true
  99. $bcopy.visible = $False
  100. $bvalidate.visible = $False
  101.  
  102.  
  103. # Gets all of the users info to be copied to the new account
  104.  
  105. $name = Get-AdUser -Identity $global:nameok -Properties *
  106. $DN = $name.distinguishedName
  107. $OldUser = [ADSI]"LDAP://$DN"
  108. $Parent = $OldUser.Parent
  109. $OU = [ADSI]$Parent
  110. $OUDN = $OU.distinguishedName
  111. $domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
  112. $NewName = "$fname $lname"
  113. $flname = "$global:fname.$global:lname"
  114. $lscript =
  115.  
  116.  
  117.  
  118. # Creates the user from the copied properties #Step 1
  119. # Added -homedrive "H" -ProfilePath "\\<YOURSERVER>\<YOURPROFILEPATH>\$global:NewUser" -homedirectory  "\\<YOURSERVER>\YOURUSERPATH>\$global:NewUser" -HomePage "www.<YOURCOMPANY>.com"
  120. New-ADUser -SamAccountName $global:NewUser -Name $NewName -GivenName $fname -Surname $lname -Instance $DN -Path "$OUDN" -AccountPassword (ConvertTo-SecureString -AsPlainText "Welcome.1" -Force) –userPrincipalName $global:NewUser@$domain -Company $name.Company -Description $name.Description -Department $name.Department -Manager $name.Manager -title $name.Title -Office $name.Office -City $name.city -PostalCode $name.postalcode -Country $name.country -OfficePhone $name.OfficePhone -StreetAddress $name.StreetAddress -Enabled $true -homedrive "H" -ProfilePath "\\<YOURSERVER>\<YOURPROFILEPATH>\$global:NewUser" -homedirectory  "\\<YOURSERVER>\YOURUSERPATH>\$global:NewUser" -HomePage "www.<YOURCOMPANY>.com"
  121. $pgbar.value = ($pgbar.value + 10)
  122.  
  123. # Requires Change Password at Logon
  124.  
  125. Set-ADUser -Identity $global:NewUser -ChangePasswordAtLogon $true
  126.  
  127. # gets groups from the Copied user and populates the new user in them #Step 2
  128.  
  129. $groups = (GET-ADUSER –Identity $name –Properties MemberOf).MemberOf
  130. $global:count = $groups.count
  131. $global:countr = $groups.count
  132. $pgtot = 290
  133. $pgbar.maximum = ($pgtot + ($global:count * 10))
  134. $infodisplay.text = "Groupe a copier: $global:count"
  135.  
  136. # Group copy
  137.  
  138. $groups = (GET-ADUSER –Identity $name –Properties MemberOf).MemberOf
  139. foreach ($group in $groups) {
  140.  
  141. Add-ADGroupMember -Identity $group -Members $global:NewUser
  142. $pgbar.value = ($pgbar.value + 10)
  143.  
  144. }
  145.  
  146.  
  147.  
  148.  
  149. # After some testing it seems that sometimes AD don't have time to process everything and while trying to access the user for exchange it gave errors.
  150. $infodisplay.Text = $infodisplay.Text + "`r`nProcessing time... "
  151. $sec = 15
  152. While($sec -ne 0) {Start-Sleep -s 1
  153. $pgbar.value = ($pgbar.value + 10)
  154. $sec--}
  155.  
  156. # Creates the New users mailbox #Step 3
  157. # removed –managedfoldermailboxpolicy "Company Retention Policies"
  158.  
  159. Enable-Mailbox -Identity $global:NewUser@$domain -alias "$flname" -Database $global:db
  160. $pgbar.value = ($pgbar.value + 10)
  161. $infodisplay.Text = $infodisplay.Text + "`r`nLinking Mailbox to $global:NewUser@$domain"
  162.  
  163. # Sets secondary smtp adress while specifying the Primary smtp adress. # Step 4
  164. $infodisplay.Text = $infodisplay.Text + "`r`nEditing Mailbox $global:NewUser@$domain for SMTP"
  165. $sec = ""
  166. $sec = 10
  167. While($sec -ne 0) {Start-Sleep -s 1
  168. $pgbar.value = ($pgbar.value + 10)
  169. $sec--}
  170.  
  171. # Address next to SMTP is the primary SMTP address
  172.  
  173. Set-Mailbox $flname -EmailAddressPolicyEnabled $False -EmailAddresses SMTP:"$flname@<YOURCOMPANY>.com", "$flname@<YOURALIAS>.<YOURALIASDOMAIN>.com"
  174.  
  175. $pgbar.value = ($pgbar.value + 10)
  176.  
  177. # Creates the New user personal Folder # Step 5
  178.  
  179. $infodisplay.Text = $infodisplay.Text + "`r`nCreating Home Folder for $global:NewUser"
  180.  
  181. New-item \\<YOURSERVER>\YOURUSERPATH>\"$global:NewUser" -type directory
  182. $acl = Get-Acl \\<YOURSERVER>\YOURUSERPATH>\"$global:NewUser"
  183. $acl | Format-List
  184. $acl.GetAccessRules($true, $true, [System.Security.Principal.NTAccount])
  185. $acl.SetAccessRuleProtection($true, $true)
  186. $rule = New-Object System.Security.AccessControl.FileSystemAccessRule "$domain\$global:NewUser","FullControl", "ContainerInherit, ObjectInherit", "None", "Allow"
  187. $acl.addAccessRule($rule)
  188. Set-Acl \\<YOURSERVER>\YOURUSERPATH>\"$global:NewUser" $acl
  189. $pgbar.value = ($pgbar.value + 10)
  190.  
  191. $infodisplay.Text = "Home Directory: Successfull"
  192.  
  193. # Creates the New user Profile Folder # Step 6
  194.  
  195. $infodisplay.Text = $infodisplay.Text + "`r`nCreating Profile Folder for $global:NewUser"
  196.  
  197. New-item \\<YOURSERVER>\<YOURPROFILEPATH>\\"$global:NewUser" -type directory
  198. $acl = Get-Acl \\<YOURSERVER>\<YOURPROFILEPATH>\\"$global:NewUser"
  199. $acl | Format-List
  200. $acl.GetAccessRules($true, $true, [System.Security.Principal.NTAccount])
  201. $acl.SetAccessRuleProtection($true, $true)
  202. $rule = New-Object System.Security.AccessControl.FileSystemAccessRule "$domain\$global:NewUser","FullControl", "ContainerInherit, ObjectInherit", "None", "Allow"
  203. $acl.addAccessRule($rule)
  204. Set-Acl \\<YOURSERVER>\<YOURPROFILEPATH>\\"$global:NewUser" $acl
  205. $pgbar.value = ($pgbar.value + 10)
  206.  
  207. $infodisplay.Text = "Profile Folder: Successfull"
  208.  
  209.  
  210. #Email report to It
  211. #Manager to Notify
  212.  
  213. $emailmgr = Get-ADUser "$mgr" -Properties EmailAddress
  214. $notifymgr = $emailmgr.EmailAddress
  215.  
  216.  
  217. $smtpServer = "<YOURMAILSERVER>"
  218. $smtpFrom = "no-reply@<YOURCOMPANY>.com"
  219.  
  220. if ($notifymgr -eq $null){$smtpTo = "help@<YOURCOMPANY>.com"}
  221. else {$smtpTo = "$notifymgr", "help@<YOURCOMPANY>.com"}
  222.  
  223. $messageSubject = "Automated User Creation Report"
  224.  
  225. [string]$messagebody = ""
  226.  
  227. $messagebody = "Name: $global:flname `r`nUsername: $global:NewUser@<YOURCOMPANY>.com  `r`nInitial Password: <YOURINITIALPASSWORD> `r`nCopy of User: $global:nameok `r`nMailbox Storage Selection : $global:db"
  228.  
  229.  
  230. Send-MailMessage -To $smtpTo -From $smtpFrom -Subject $messagesubject -Body $messagebody -SmtpServer $smtpServer
  231.  
  232. #Welcome letter to user
  233.  
  234. $messageSubject = "Welcome To <YOURCOMPANY>"
  235. $smtpTo = "$global:fname.$global:lname@<YOURCOMPANY>.com"
  236.  
  237. $messagebody = "Hello, $global:fname $global:lname, and welcome to the <YOURCOMPANY>. Please keep this email for future use. It contains vital information.
  238.  
  239. -----------------------------------
  240. Username and Password
  241. -----------------------------------
  242. Your network username is $global:NewUser, and your initial password is <YOURPASSWORD> . Use your username and password to log on to the network. You will be prompted to change your password upon first login. Your password should NEVER be shared with anyone. You will be prompted to change it regularly.
  243.  
  244. -----------------------------------
  245. Email
  246. -----------------------------------
  247. Your logon address is $global:fname.$global:lname@<YOURCOMPANY>.com.
  248.  
  249. To access your email, calendar, and contacts away from your desk, you can do so from any Internet-connected computer. Simply open your web browser, go to the Outlook Web Access (OWA) page at  https://webmail.<YOURCOMPANY>.com/owa, and log in using your email address and network password. Please note the S in https.
  250.  
  251. -----------------------------------
  252. Personal Folder
  253. -----------------------------------
  254. A personal folder has been created for you, located at H:\.  Any file or folder in your H: drive will be included in our daily backup. No file stored on your local computer will be backed up, so be sure all important files and documents are in your H: drive!
  255.  
  256. -----------------------------------
  257. Technical Assistance
  258. -----------------------------------
  259. Should you need technical assistance, please send an email to <SUPPORT>@<YOURCOMPANY>.com if urgent follow up with a phone call to <YOUREXTENSION>.
  260.  
  261. Thank you.
  262.  
  263. Technical Services"
  264.  
  265.  
  266.  
  267. Send-MailMessage -To $smtpTo -From $smtpFrom -Subject $messagesubject -Body $messagebody -SmtpServer $smtpServer
  268.  
  269. $clear.visible = $True
  270.  
  271. }
  272.  
  273. $bvalidate_OnClick=
  274. {
  275. # Gets all of the users info to be copied to the new account
  276.  
  277. #array index selection
  278. $global:index = $tuser.SelectedIndex
  279. $indexuser = $arrac[$index]
  280. $iuser = get-aduser  $indexuser.SamAccountName  | select -ExpandProperty SamAccountName
  281. $global:nameds = $iuser
  282. $global:nameok = $iuser
  283.  
  284. #Array mgr selection
  285. if ($cmbmgr.SelectedIndex -eq -1){$global:mgr = ""}
  286. else {
  287. $global:index2 = $cmbmgr.SelectedIndex
  288. $indexmgr = $arrac[$index2]
  289. $global:mgr = get-aduser  $indexmgr.SamAccountName  | select -ExpandProperty SamAccountName}
  290.  
  291. #Checking the user to copy if it exist
  292.  
  293. if ($tuser.SelectedIndex -eq -1) {$val1.Text = "Not OK"
  294. $global:nameok = ""}
  295.  
  296. else {$val1.Text = "OK"}
  297.  
  298.  
  299.  
  300. #Checking if the new user exist
  301.  
  302. $global:NewUserds = $tnewuser.Text
  303. $global:NewUser = $global:NewUserds
  304.  
  305. if ( $global:NewUserds -eq "" ) {$val2.Text = "Empty"}
  306.    
  307. elseif (dsquery user -samid $global:NewUserds){$val2.Text = "User Exist"}
  308.  
  309. elseif ($global:NewUserds = "null") {$val2.Text = "OK"}
  310.  
  311. #Checking if Fisrt Name isn't empty
  312.  
  313. if ( $tfname.Text -eq "" ) {$val3.Text = "Empty"}
  314. elseif ($tfname.Text -ne "") {$val3.Text = "OK"}
  315. $global:fname = $tfname.Text
  316.  
  317. #Checking if Last Name isn't empty
  318.  
  319. if ( $tlname.Text -eq "" ) {$val4.Text = "Empty"}
  320. elseif ($tlname.Text -ne "") {$val4.Text = "OK"}
  321. $global:lname = $tlname.Text
  322.  
  323. #Checking if hte Mailbox Storage is selected
  324.  
  325. if ($mailboxlist.SelectedIndex -eq "-1") {
  326. $val5.Text = "No Selection"
  327. $infodisplay.Text = "Please Select a Mailbox Storage"
  328. }
  329. else {$val5.Text = "OK"}
  330.  
  331. $global:db = $mailboxlist.Selecteditem
  332.  
  333.  
  334. #Checking if All Validation is OK
  335.  
  336. if ( $val1.Text -eq "OK" -and $val2.Text -eq "OK" -and $val3.Text -eq "OK" -and $val4.Text -eq "OK" -and $val5.Text -eq "OK") {
  337. $tuser.enabled = $False
  338. $tnewuser.enabled = $False
  339. $tfname.enabled = $False
  340. $tlname.enabled = $False
  341. $mailboxlist.enabled = $False
  342. $cmbmgr.enabled = $false
  343. $clear.visible = $True
  344. $bcopy.visible = $True }
  345.  
  346. #Displaying Info
  347. $nmgr = $cmbmgr.SelectedItem
  348. $infodisplay.Text = "Manager to notify: $nmgr `r`nUser to Copy: $global:nameok `r`nLogon Name of New user: $global:NewUser `r`nFirst Name: $global:fname `r`nLast Name : $global:lname `r`nMailbox Storage Selection : $global:db "
  349.  
  350.  
  351. }
  352.  
  353. $handler_label1_Click=
  354. {
  355. #TODO: Place custom script here
  356.  
  357. }
  358.  
  359. $clear_OnClick=
  360. {
  361.  
  362. $tuser.enabled = $True
  363. $tnewuser.enabled = $True
  364. $tfname.enabled = $True
  365. $tlname.enabled = $True
  366. $mailboxlist.enabled = $True
  367. $cmbmgr.enabled = $true
  368. $val1.Text = ""
  369. $val2.Text = ""
  370. $val3.Text = ""
  371. $val4.Text = ""
  372. $val5.Text = ""
  373. $tuser.SelectedIndex = -1
  374. $cmbmgr.SelectedIndex = -1
  375. $tnewuser.Text = ""
  376. $tfname.Text = ""
  377. $tlname.Text = ""
  378. $infodisplay.Text = ""
  379. $pgbar.value = 0
  380. $pgbar.maximum = 0
  381. $clear.visible = $False
  382. $bcopy.visible = $False
  383.  
  384. $bvalidate.visible = $True
  385. $mailboxlist.clearSelected()
  386.  
  387. }
  388.  
  389. $handler_form1_Load=
  390. {
  391. #TODO: Place custom script here
  392.  
  393. }
  394.  
  395. $OnLoadForm_StateCorrection=
  396. {#Correct the initial state of the form to prevent the .Net maximized form issue
  397.     $form1.WindowState = $InitialFormWindowState
  398. }
  399.  
  400. #----------------------------------------------
  401. #region Generated Form Code
  402. $System_Drawing_Size = New-Object System.Drawing.Size
  403. $System_Drawing_Size.Height = 394
  404. $System_Drawing_Size.Width = 534
  405. $form1.ClientSize = $System_Drawing_Size
  406. $form1.DataBindings.DefaultDataSourceUpdateMode = 0
  407. $form1.Name = "form1"
  408. $form1.Text = "Ad Copy User"
  409. $form1.add_Load($handler_form1_Load)
  410.  
  411. $lmanager.DataBindings.DefaultDataSourceUpdateMode = 0
  412.  
  413. $System_Drawing_Point = New-Object System.Drawing.Point
  414. $System_Drawing_Point.X = 38
  415. $System_Drawing_Point.Y = 15
  416. $lmanager.Location = $System_Drawing_Point
  417. $lmanager.Name = "lmanager"
  418. $System_Drawing_Size = New-Object System.Drawing.Size
  419. $System_Drawing_Size.Height = 23
  420. $System_Drawing_Size.Width = 84
  421. $lmanager.Size = $System_Drawing_Size
  422. $lmanager.TabIndex = 24
  423. $lmanager.Text = "Notify Manager"
  424.  
  425. $form1.Controls.Add($lmanager)
  426.  
  427. $cmbmgr.AutoCompleteMode = 3
  428. $cmbmgr.AutoCompleteSource = 256
  429. $cmbmgr.DataBindings.DefaultDataSourceUpdateMode = 0
  430. $cmbmgr.FormattingEnabled = $True
  431. $System_Drawing_Point = New-Object System.Drawing.Point
  432. $System_Drawing_Point.X = 128
  433. $System_Drawing_Point.Y = 11
  434. $cmbmgr.Location = $System_Drawing_Point
  435. $cmbmgr.Name = "cmbmgr"
  436. $System_Drawing_Size = New-Object System.Drawing.Size
  437. $System_Drawing_Size.Height = 21
  438. $System_Drawing_Size.Width = 145
  439. $cmbmgr.Size = $System_Drawing_Size
  440. $cmbmgr.TabIndex = 23
  441.  
  442. $form1.Controls.Add($cmbmgr)
  443.  
  444. $val5.DataBindings.DefaultDataSourceUpdateMode = 0
  445.  
  446. $System_Drawing_Point = New-Object System.Drawing.Point
  447. $System_Drawing_Point.X = 287
  448. $System_Drawing_Point.Y = 204
  449. $val5.Location = $System_Drawing_Point
  450. $val5.Name = "val5"
  451. $System_Drawing_Size = New-Object System.Drawing.Size
  452. $System_Drawing_Size.Height = 18
  453. $System_Drawing_Size.Width = 108
  454. $val5.Size = $System_Drawing_Size
  455. $val5.TabIndex = 22
  456.  
  457. $form1.Controls.Add($val5)
  458.  
  459.  
  460. #$pictureBox1.DataBindings.DefaultDataSourceUpdateMode = 0
  461.  
  462.  
  463. #$pictureBox1.InitialImage = [System.Drawing.Image]::FromFile('\\sequoia\installs$\hut_logo.jpg')
  464. #$System_Drawing_Point = New-Object System.Drawing.Point
  465. #$System_Drawing_Point.X = 336
  466. #$System_Drawing_Point.Y = 261
  467. #$pictureBox1.Location = $System_Drawing_Point
  468. #$pictureBox1.Name = "pictureBox1"
  469. #$System_Drawing_Size = New-Object System.Drawing.Size
  470. #$System_Drawing_Size.Height = 109
  471. #$System_Drawing_Size.Width = 185
  472. #$pictureBox1.Size = $System_Drawing_Size
  473. #$pictureBox1.TabIndex = 21
  474. #$pictureBox1.TabStop = $False
  475.  
  476. #$form1.Controls.Add($pictureBox1)
  477.  
  478. $pgbar.DataBindings.DefaultDataSourceUpdateMode = 0
  479. $System_Drawing_Point = New-Object System.Drawing.Point
  480. $System_Drawing_Point.X = 39
  481. $System_Drawing_Point.Y = 149
  482. $pgbar.Location = $System_Drawing_Point
  483. $pgbar.Name = "pgbar"
  484. $System_Drawing_Size = New-Object System.Drawing.Size
  485. $System_Drawing_Size.Height = 28
  486. $System_Drawing_Size.Width = 234
  487. $pgbar.Size = $System_Drawing_Size
  488. $pgbar.TabIndex = 20
  489. $pgbar.Visible = $False
  490.  
  491. $form1.Controls.Add($pgbar)
  492.  
  493. $infodisplay.DataBindings.DefaultDataSourceUpdateMode = 0
  494.  
  495. $System_Drawing_Point = New-Object System.Drawing.Point
  496. $System_Drawing_Point.X = 12
  497. $System_Drawing_Point.Y = 255
  498. $infodisplay.Location = $System_Drawing_Point
  499. $infodisplay.Name = "infodisplay"
  500. $System_Drawing_Size = New-Object System.Drawing.Size
  501. $System_Drawing_Size.Height = 116
  502. $System_Drawing_Size.Width = 311
  503. $infodisplay.Size = $System_Drawing_Size
  504. $infodisplay.TabIndex = 19
  505.  
  506. $form1.Controls.Add($infodisplay)
  507.  
  508. $tuser.AutoCompleteMode = 3
  509. $tuser.AutoCompleteSource = 256
  510. $tuser.DataBindings.DefaultDataSourceUpdateMode = 0
  511. $tuser.FormattingEnabled = $True
  512. $System_Drawing_Point = New-Object System.Drawing.Point
  513. $System_Drawing_Point.X = 128
  514. $System_Drawing_Point.Y = 38
  515. $tuser.Location = $System_Drawing_Point
  516. $tuser.Name = "tuser"
  517. $System_Drawing_Size = New-Object System.Drawing.Size
  518. $System_Drawing_Size.Height = 21
  519. $System_Drawing_Size.Width = 145
  520. $tuser.Size = $System_Drawing_Size
  521. $tuser.TabIndex = 1
  522.  
  523. $form1.Controls.Add($tuser)
  524.  
  525.  
  526. $clear.DataBindings.DefaultDataSourceUpdateMode = 0
  527.  
  528. $System_Drawing_Point = New-Object System.Drawing.Point
  529. $System_Drawing_Point.X = 413
  530. $System_Drawing_Point.Y = 178
  531. $clear.Location = $System_Drawing_Point
  532. $clear.Name = "clear"
  533. $System_Drawing_Size = New-Object System.Drawing.Size
  534. $System_Drawing_Size.Height = 24
  535. $System_Drawing_Size.Width = 110
  536. $clear.Size = $System_Drawing_Size
  537. $clear.TabIndex = 16
  538. $clear.Text = "Clear"
  539. $clear.UseVisualStyleBackColor = $True
  540. $clear.Visible = $False
  541. $clear.add_Click($clear_OnClick)
  542.  
  543. $form1.Controls.Add($clear)
  544.  
  545. $val4.DataBindings.DefaultDataSourceUpdateMode = 0
  546.  
  547. $System_Drawing_Point = New-Object System.Drawing.Point
  548. $System_Drawing_Point.X = 290
  549. $System_Drawing_Point.Y = 119
  550. $val4.Location = $System_Drawing_Point
  551. $val4.Name = "val4"
  552. $System_Drawing_Size = New-Object System.Drawing.Size
  553. $System_Drawing_Size.Height = 18
  554. $System_Drawing_Size.Width = 108
  555. $val4.Size = $System_Drawing_Size
  556. $val4.TabIndex = 15
  557.  
  558. $form1.Controls.Add($val4)
  559.  
  560. $val3.DataBindings.DefaultDataSourceUpdateMode = 0
  561.  
  562. $System_Drawing_Point = New-Object System.Drawing.Point
  563. $System_Drawing_Point.X = 290
  564. $System_Drawing_Point.Y = 93
  565. $val3.Location = $System_Drawing_Point
  566. $val3.Name = "val3"
  567. $System_Drawing_Size = New-Object System.Drawing.Size
  568. $System_Drawing_Size.Height = 18
  569. $System_Drawing_Size.Width = 108
  570. $val3.Size = $System_Drawing_Size
  571. $val3.TabIndex = 14
  572.  
  573. $form1.Controls.Add($val3)
  574.  
  575. $mailboxlist.DataBindings.DefaultDataSourceUpdateMode = 0
  576. $mailboxlist.FormattingEnabled = $True
  577. $System_Drawing_Point = New-Object System.Drawing.Point
  578. $System_Drawing_Point.X = 38
  579. $System_Drawing_Point.Y = 194
  580. $mailboxlist.Location = $System_Drawing_Point
  581. $mailboxlist.Name = "mailboxlist"
  582. $System_Drawing_Size = New-Object System.Drawing.Size
  583. $System_Drawing_Size.Height = 43
  584. $System_Drawing_Size.Width = 190
  585. $mailboxlist.Size = $System_Drawing_Size
  586. $mailboxlist.TabIndex = 13
  587.  
  588. $form1.Controls.Add($mailboxlist)
  589.  
  590.  
  591. $bcopy.DataBindings.DefaultDataSourceUpdateMode = 0
  592.  
  593. $System_Drawing_Point = New-Object System.Drawing.Point
  594. $System_Drawing_Point.X = 412
  595. $System_Drawing_Point.Y = 149
  596. $bcopy.Location = $System_Drawing_Point
  597. $bcopy.Name = "bcopy"
  598. $System_Drawing_Size = New-Object System.Drawing.Size
  599. $System_Drawing_Size.Height = 24
  600. $System_Drawing_Size.Width = 110
  601. $bcopy.Size = $System_Drawing_Size
  602. $bcopy.TabIndex = 12
  603. $bcopy.Text = "Start Copy"
  604. $bcopy.UseVisualStyleBackColor = $True
  605. $bcopy.Visible = $False
  606. $bcopy.add_Click($bcopy_OnClick)
  607.  
  608. $form1.Controls.Add($bcopy)
  609.  
  610. $val2.DataBindings.DefaultDataSourceUpdateMode = 0
  611.  
  612. $System_Drawing_Point = New-Object System.Drawing.Point
  613. $System_Drawing_Point.X = 290
  614. $System_Drawing_Point.Y = 67
  615. $val2.Location = $System_Drawing_Point
  616. $val2.Name = "val2"
  617. $System_Drawing_Size = New-Object System.Drawing.Size
  618. $System_Drawing_Size.Height = 18
  619. $System_Drawing_Size.Width = 108
  620. $val2.Size = $System_Drawing_Size
  621. $val2.TabIndex = 11
  622.  
  623. $form1.Controls.Add($val2)
  624.  
  625. $val1.DataBindings.DefaultDataSourceUpdateMode = 0
  626.  
  627. $System_Drawing_Point = New-Object System.Drawing.Point
  628. $System_Drawing_Point.X = 290
  629. $System_Drawing_Point.Y = 41
  630. $val1.Location = $System_Drawing_Point
  631. $val1.Name = "val1"
  632. $System_Drawing_Size = New-Object System.Drawing.Size
  633. $System_Drawing_Size.Height = 18
  634. $System_Drawing_Size.Width = 108
  635. $val1.Size = $System_Drawing_Size
  636. $val1.TabIndex = 10
  637.  
  638. $form1.Controls.Add($val1)
  639.  
  640.  
  641. $bvalidate.DataBindings.DefaultDataSourceUpdateMode = 0
  642.  
  643. $System_Drawing_Point = New-Object System.Drawing.Point
  644. $System_Drawing_Point.X = 412
  645. $System_Drawing_Point.Y = 119
  646. $bvalidate.Location = $System_Drawing_Point
  647. $bvalidate.Name = "bvalidate"
  648. $System_Drawing_Size = New-Object System.Drawing.Size
  649. $System_Drawing_Size.Height = 24
  650. $System_Drawing_Size.Width = 110
  651. $bvalidate.Size = $System_Drawing_Size
  652. $bvalidate.TabIndex = 9
  653. $bvalidate.Text = "Validate"
  654. $bvalidate.UseVisualStyleBackColor = $True
  655. $bvalidate.add_Click($bvalidate_OnClick)
  656.  
  657. $form1.Controls.Add($bvalidate)
  658.  
  659. $label4.DataBindings.DefaultDataSourceUpdateMode = 0
  660.  
  661. $System_Drawing_Point = New-Object System.Drawing.Point
  662. $System_Drawing_Point.X = 38
  663. $System_Drawing_Point.Y = 119
  664. $label4.Location = $System_Drawing_Point
  665. $label4.Name = "label4"
  666. $System_Drawing_Size = New-Object System.Drawing.Size
  667. $System_Drawing_Size.Height = 19
  668. $System_Drawing_Size.Width = 84
  669. $label4.Size = $System_Drawing_Size
  670. $label4.TabIndex = 8
  671. $label4.Text = "Lastname"
  672.  
  673. $form1.Controls.Add($label4)
  674.  
  675. $label3.DataBindings.DefaultDataSourceUpdateMode = 0
  676.  
  677. $System_Drawing_Point = New-Object System.Drawing.Point
  678. $System_Drawing_Point.X = 38
  679. $System_Drawing_Point.Y = 95
  680. $label3.Location = $System_Drawing_Point
  681. $label3.Name = "label3"
  682. $System_Drawing_Size = New-Object System.Drawing.Size
  683. $System_Drawing_Size.Height = 19
  684. $System_Drawing_Size.Width = 84
  685. $label3.Size = $System_Drawing_Size
  686. $label3.TabIndex = 7
  687. $label3.Text = "First Name"
  688.  
  689. $form1.Controls.Add($label3)
  690.  
  691. $label2.DataBindings.DefaultDataSourceUpdateMode = 0
  692.  
  693. $System_Drawing_Point = New-Object System.Drawing.Point
  694. $System_Drawing_Point.X = 38
  695. $System_Drawing_Point.Y = 69
  696. $label2.Location = $System_Drawing_Point
  697. $label2.Name = "label2"
  698. $System_Drawing_Size = New-Object System.Drawing.Size
  699. $System_Drawing_Size.Height = 19
  700. $System_Drawing_Size.Width = 84
  701. $label2.Size = $System_Drawing_Size
  702. $label2.TabIndex = 6
  703. $label2.Text = "New Username"
  704.  
  705. $form1.Controls.Add($label2)
  706.  
  707. $label1.DataBindings.DefaultDataSourceUpdateMode = 0
  708.  
  709. $System_Drawing_Point = New-Object System.Drawing.Point
  710. $System_Drawing_Point.X = 38
  711. $System_Drawing_Point.Y = 43
  712. $label1.Location = $System_Drawing_Point
  713. $label1.Name = "label1"
  714. $System_Drawing_Size = New-Object System.Drawing.Size
  715. $System_Drawing_Size.Height = 19
  716. $System_Drawing_Size.Width = 84
  717. $label1.Size = $System_Drawing_Size
  718. $label1.TabIndex = 5
  719. $label1.Text = "User to Copy"
  720. $label1.add_Click($handler_label1_Click)
  721.  
  722. $form1.Controls.Add($label1)
  723.  
  724. $tlname.DataBindings.DefaultDataSourceUpdateMode = 0
  725. $System_Drawing_Point = New-Object System.Drawing.Point
  726. $System_Drawing_Point.X = 128
  727. $System_Drawing_Point.Y = 119
  728. $tlname.Location = $System_Drawing_Point
  729. $tlname.Name = "tlname"
  730. $System_Drawing_Size = New-Object System.Drawing.Size
  731. $System_Drawing_Size.Height = 20
  732. $System_Drawing_Size.Width = 145
  733. $tlname.Size = $System_Drawing_Size
  734. $tlname.TabIndex = 4
  735.  
  736. $form1.Controls.Add($tlname)
  737.  
  738. $tfname.DataBindings.DefaultDataSourceUpdateMode = 0
  739. $System_Drawing_Point = New-Object System.Drawing.Point
  740. $System_Drawing_Point.X = 128
  741. $System_Drawing_Point.Y = 93
  742. $tfname.Location = $System_Drawing_Point
  743. $tfname.Name = "tfname"
  744. $System_Drawing_Size = New-Object System.Drawing.Size
  745. $System_Drawing_Size.Height = 20
  746. $System_Drawing_Size.Width = 145
  747. $tfname.Size = $System_Drawing_Size
  748. $tfname.TabIndex = 3
  749.  
  750. $form1.Controls.Add($tfname)
  751.  
  752. $tnewuser.DataBindings.DefaultDataSourceUpdateMode = 0
  753. $System_Drawing_Point = New-Object System.Drawing.Point
  754. $System_Drawing_Point.X = 128
  755. $System_Drawing_Point.Y = 67
  756. $tnewuser.Location = $System_Drawing_Point
  757. $tnewuser.Name = "tnewuser"
  758. $System_Drawing_Size = New-Object System.Drawing.Size
  759. $System_Drawing_Size.Height = 20
  760. $System_Drawing_Size.Width = 145
  761. $tnewuser.Size = $System_Drawing_Size
  762. $tnewuser.TabIndex = 2
  763.  
  764. $form1.Controls.Add($tnewuser)
  765.  
  766. #endregion Generated Form Code
  767.  
  768. #Save the initial state of the form
  769. $InitialFormWindowState = $form1.WindowState
  770. #Init the OnLoad event to correct the initial state of the form
  771. $form1.add_Load($OnLoadForm_StateCorrection)
  772. #Show the Form
  773. $form1.ShowDialog()| Out-Null
  774.  
  775. } #End Function
  776.  
  777. #Call the Function
  778. GenerateForm
RAW Paste Data