Add 'ADUser_GUI-Functions.ps1'
Signed-off-by: Tre Hayes <thayes@noreply.homeserver.local>
This commit is contained in:
parent
06ae485c1c
commit
437efbbc33
151
ADUser_GUI-Functions.ps1
Normal file
151
ADUser_GUI-Functions.ps1
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
function manualBuild ($form_Controls) {
|
||||||
|
$empID_Label.Enabled = $true
|
||||||
|
$empID_Label.Visible = $true
|
||||||
|
$empID_TextBox.Enabled = $true
|
||||||
|
$empID_TextBox.Visible = $true
|
||||||
|
$fName_Label.Enabled = $true
|
||||||
|
$fName_Label.Visible = $true
|
||||||
|
$fName_TextBox.Enabled = $true
|
||||||
|
$fName_TextBox.Visible = $true
|
||||||
|
$mInitial_Label.Enabled = $true
|
||||||
|
$mInitial_Label.Visible = $true
|
||||||
|
$mInitial_TextBox.Enabled = $true
|
||||||
|
$mInitial_TextBox.Visible = $true
|
||||||
|
$lName_Label.Enabled = $true
|
||||||
|
$lName_Label.Visible = $true
|
||||||
|
$lName_TextBox.Enabled = $true
|
||||||
|
$lName_TextBox.Visible = $true
|
||||||
|
$nickName_Label.Enabled = $true
|
||||||
|
$nickName_Label.Visible = $true
|
||||||
|
$nickName_TextBox.Enabled = $true
|
||||||
|
$nickName_TextBox.Visible = $true
|
||||||
|
$deptCode_Label.Enabled = $true
|
||||||
|
$deptCode_Label.Visible = $true
|
||||||
|
$deptCode_TextBox.Enabled = $false
|
||||||
|
$deptCode_TextBox.Visible = $true
|
||||||
|
$deptName_Label.Enabled = $true
|
||||||
|
$deptName_Label.Visible = $true
|
||||||
|
$deptName_ComboBox.Enabled = $true
|
||||||
|
$deptName_ComboBox.Visible = $true
|
||||||
|
$jobCode_Label.Enabled = $true
|
||||||
|
$jobCode_Label.Visible = $true
|
||||||
|
$jobCode_TextBox.Enabled = $false
|
||||||
|
$jobCode_TextBox.Visible = $true
|
||||||
|
$jobTitle_Label.Enabled = $true
|
||||||
|
$jobTitle_Label.Visible = $true
|
||||||
|
$jobTitle_ComboBox.Enabled = $true
|
||||||
|
$jobTitle_ComboBox.Visible = $true
|
||||||
|
$vp_Label.Enabled = $true
|
||||||
|
$vp_Label.Visible = $true
|
||||||
|
$vp_TextBox.Enabled = $false
|
||||||
|
$vp_TextBox.Visible = $true
|
||||||
|
$csvPath_Label.Enabled = $false
|
||||||
|
$csvPath_Label.Visible = $false
|
||||||
|
}
|
||||||
|
|
||||||
|
function csvBuild ($form_Controls) {
|
||||||
|
$empID_Label.Enabled = $false
|
||||||
|
$empID_Label.Visible = $false
|
||||||
|
$empID_TextBox.Enabled = $false
|
||||||
|
$empID_TextBox.Visible = $false
|
||||||
|
$fName_Label.Enabled = $false
|
||||||
|
$fName_Label.Visible = $false
|
||||||
|
$fName_TextBox.Enabled = $false
|
||||||
|
$fName_TextBox.Visible = $false
|
||||||
|
$mInitial_Label.Enabled = $false
|
||||||
|
$mInitial_Label.Visible = $false
|
||||||
|
$mInitial_TextBox.Enabled = $false
|
||||||
|
$mInitial_TextBox.Visible = $false
|
||||||
|
$lName_Label.Enabled = $false
|
||||||
|
$lName_Label.Visible = $false
|
||||||
|
$lName_TextBox.Enabled = $false
|
||||||
|
$lName_TextBox.Visible = $false
|
||||||
|
$nickName_Label.Enabled = $false
|
||||||
|
$nickName_Label.Visible = $false
|
||||||
|
$nickName_TextBox.Enabled = $false
|
||||||
|
$nickName_TextBox.Visible = $false
|
||||||
|
$deptCode_Label.Enabled = $false
|
||||||
|
$deptCode_Label.Visible = $false
|
||||||
|
$deptCode_TextBox.Enabled = $false
|
||||||
|
$deptCode_TextBox.Visible = $false
|
||||||
|
$deptName_Label.Enabled = $false
|
||||||
|
$deptName_Label.Visible = $false
|
||||||
|
$deptName_ComboBox.Enabled = $false
|
||||||
|
$deptName_ComboBox.Visible = $false
|
||||||
|
$jobCode_Label.Enabled = $false
|
||||||
|
$jobCode_Label.Visible = $false
|
||||||
|
$jobCode_TextBox.Enabled = $false
|
||||||
|
$jobCode_TextBox.Visible = $false
|
||||||
|
$jobTitle_Label.Enabled = $false
|
||||||
|
$jobTitle_Label.Visible = $false
|
||||||
|
$jobTitle_ComboBox.Enabled = $false
|
||||||
|
$jobTitle_ComboBox.Visible = $false
|
||||||
|
$vp_Label.Enabled = $false
|
||||||
|
$vp_Label.Visible = $false
|
||||||
|
$vp_TextBox.Enabled = $false
|
||||||
|
$vp_TextBox.Visible = $false
|
||||||
|
$csvPath_Label.Enabled = $true
|
||||||
|
$csvPath_Label.Visible = $true
|
||||||
|
clear-Fields
|
||||||
|
}
|
||||||
|
|
||||||
|
function build-UserLog {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory=$true)] [string]$empID
|
||||||
|
)
|
||||||
|
$log_Time = Get-Date -Format "MM-dd-yyyy"
|
||||||
|
$log_File = '.\Users Built_'+$log_Time+'.csv'
|
||||||
|
Get-ADUser -Identity $empID -Properties SamAccountName,Name,Department,Description | `
|
||||||
|
Select-Object @{l='Time Built';e={Get-Date}},@{l='Builder';e={$env:username}},@{l='Employee ID';e={$_.SamAccountName}},Name,Department,@{l='Job Title';e={$_.Description}} | `
|
||||||
|
Export-Csv -Path $log_File -Append -NoTypeInformation
|
||||||
|
}
|
||||||
|
|
||||||
|
function clear-Fields {
|
||||||
|
$empID_TextBox.Clear()
|
||||||
|
$fName_TextBox.Clear()
|
||||||
|
$mInitial_TextBox.Clear()
|
||||||
|
$lName_TextBox.Clear()
|
||||||
|
$nickName_TextBox.Clear()
|
||||||
|
$deptName_ComboBox.SelectedIndex = 0
|
||||||
|
$jobTitle_ComboBox.SelectedIndex = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function set-JobCode ($jobTitle) {
|
||||||
|
foreach ($job in $jobs) {
|
||||||
|
switch ($jobTitle) {
|
||||||
|
$job.'Job Description' {$jobCode_TextBox.Text = $job.'Job Code'}
|
||||||
|
'' {$jobCode_TextBox.Text = ''}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function set-DeptCode ($deptName) {
|
||||||
|
foreach ($dept in $departments) {
|
||||||
|
switch ($deptName) {
|
||||||
|
$dept.'DepartmentName' {
|
||||||
|
$deptCode_TextBox.Text = ($dept.'Deparment').replace(' ','')
|
||||||
|
$vp_TextBox.Text = $dept.'VP Name'
|
||||||
|
}
|
||||||
|
'' {$deptCode_TextBox.Text = ''; $vp_TextBox.Text = ''}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function select-All ($textBox) {
|
||||||
|
if (($textBox.Control) -and ($textBox.KeyCode -eq 'A')) {$nickName_TextBox.SelectAll()}
|
||||||
|
}
|
||||||
|
|
||||||
|
function validate-BoxesAndCombos () {
|
||||||
|
if($empID_TextBox.Text -and $fName_TextBox.Text -and $lName_TextBox.Text -and $deptName_ComboBox.Text -and $jobTitle_ComboBox.Text) {
|
||||||
|
$build_User_Button.Enabled = $true
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$build_User_Button.Enabled = $false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function validate-RadioButtons () {
|
||||||
|
if ($csvBuild_RadioButton.Checked) { $build_User_Button.Enabled = $true }
|
||||||
|
else { $build_User_Button.Enabled = $false }
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user