OS – win 10
Os version – 64b
Basic idea, AD user creations, goal to see if there is a way to automatically populate 3 variables.
1. To populate/display the given name and last name automatically – Display name
2. Count the given name, count “.” and count the last name.
a. Apples(given) then add “.”, then counts Grapes(last)
b. Total of 13
c. Display total as typing
3. If able to get 2 to work correctly, then if the character count is over 20. To show an error or warning – something to get attention.
This is just really a rough outline of the script below, included is a screen shot of the GUI. On the GUI there is a button to press that will display the first and last, but that is a manual trigger. (Screen shot, out is right below “display name”
I think that if I am able to get these few things working I will be able to finish and put the “Create User” button script in. *took out because I forgot I put in place and was creating users.
Any guidance would be helpful.
- $form1_Load={
- #TODO: Initialize Form Controls here
- }
- $EmployeeNumber_Click={
- #TODO: Place custom script here
- }
- $employeeID_TextChanged={
- #TODO: Place custom script here
- #$employeeID_TextChanged = Read-Host 'Please enter Emp ID'
- }
- $labelDepartment_Click={
- #TODO: Place custom script here
- }
- $department_TextChanged={
- #TODO: Place custom script here
- }
- #region Control Helper Functions
- function Update-ComboBox
- {
- <#
- .SYNOPSIS
- This functions helps you load items into a ComboBox.
- .DESCRIPTION
- Use this function to dynamically load items into the ComboBox control.
- .PARAMETER ComboBox
- The ComboBox control you want to add items to.
- .PARAMETER Items
- The object or objects you wish to load into the ComboBox's Items collection.
- .PARAMETER DisplayMember
- Indicates the property to display for the items in this control.
- .PARAMETER ValueMember
- Indicates the property to use for the value of the control.
- .PARAMETER Append
- Adds the item(s) to the ComboBox without clearing the Items collection.
- .EXAMPLE
- Update-ComboBox $combobox1 "Red", "White", "Blue"
- .EXAMPLE
- Update-ComboBox $combobox1 "Red" -Append
- Update-ComboBox $combobox1 "White" -Append
- Update-ComboBox $combobox1 "Blue" -Append
- .EXAMPLE
- Update-ComboBox $combobox1 (Get-Process) "ProcessName"
- .NOTES
- Additional information about the function.
- #>
- param
- (
- [Parameter(Mandatory = $true)]
- [ValidateNotNull()]
- [System.Windows.Forms.ComboBox]
- $ComboBox,
- [Parameter(Mandatory = $true)]
- [ValidateNotNull()]
- $Items,
- [Parameter(Mandatory = $false)]
- [string]$DisplayMember,
- [Parameter(Mandatory = $false)]
- [string]$ValueMember,
- [switch]
- $Append
- )
- if (-not $Append)
- {
- $ComboBox.Items.Clear()
- }
- if ($Items -is [Object[]])
- {
- $ComboBox.Items.AddRange($Items)
- }
- elseif ($Items -is [System.Collections.IEnumerable])
- {
- $ComboBox.BeginUpdate()
- foreach ($obj in $Items)
- {
- $ComboBox.Items.Add($obj)
- }
- $ComboBox.EndUpdate()
- }
- else
- {
- $ComboBox.Items.Add($Items)
- }
- $ComboBox.DisplayMember = $DisplayMember
- $ComboBox.ValueMember = $ValueMember
- }
- #endregion
- $officelocation_SelectedIndexChanged={
- #TODO: Place custom script here
- }
- $GivenName_TextChanged={
- #TODO: Place custom script here
- }
- $buttonCreateUser_Click={
- #TODO: Place custom script here
- Import-Module ActiveDirectory
- }
- $Displaynametext_TextChanged={
- #TODO: Place custom script here
- <#
- $Displaynametext_TextChanged = $GivenName_TextChanged + $Surname_TextChanged
- #>
- }
- $Surname_TextChanged={
- #TODO: Place custom script here
- }
- $displaynameload_Click={
- #TODO: Place custom script here
- $First = $GivenName.text
- $last = $Surname.Text
- $labeldisplayname.Text = $First + " " + $last
- }