[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Script help Request: Powershell Studio form, error handling

Posted on 2014-03-21
3
Medium Priority
?
1,454 Views
Last Modified: 2014-03-26
Looking for help scripting for error handling, See the code below:

#------------------------------------------------------------------------
# 
#========================================================================
# Code Generated By: SAPIEN Technologies, Inc., PowerShell Studio 2012 v3.1.26
# Generated On: 3/21/2014 11:27 AM
# Generated By: bhart
#========================================================================
#----------------------------------------------
#region Application Functions
#----------------------------------------------

function OnApplicationLoad {
	#Note: This function is not called in Projects
	#Note: This function runs before the form is created
	#Note: To get the script directory in the Packager use: Split-Path $hostinvocation.MyCommand.path
	#Note: To get the console output in the Packager (Windows Mode) use: $ConsoleOutput (Type: System.Collections.ArrayList)
	#Important: Form controls cannot be accessed in this function
	#TODO: Add snapins and custom code to validate the application load
	Import-Module ActiveDirectory
	
	return $true #return true for success or false for failure
}

function OnApplicationExit {
	#Note: This function is not called in Projects
	#Note: This function runs after the form is closed
	#TODO: Add custom code to clean up and unload snapins when the application exits
	
	$script:ExitCode = 0 #Set the exit code for the Packager
}

#endregion Application Functions

#----------------------------------------------
# Generated Form Function
#----------------------------------------------
function Call-HR_User_Change_pff {

	#----------------------------------------------
	#region Import the Assemblies
	#----------------------------------------------
	[void][reflection.assembly]::Load("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
	[void][reflection.assembly]::Load("System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
	[void][reflection.assembly]::Load("System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
	[void][reflection.assembly]::Load("System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
	#endregion Import Assemblies

	#----------------------------------------------
	#region Generated Form Objects
	#----------------------------------------------
	[System.Windows.Forms.Application]::EnableVisualStyles()
	$formHRUserEdit = New-Object 'System.Windows.Forms.Form'
	$statusstrip1 = New-Object 'System.Windows.Forms.StatusStrip'
	$button3 = New-Object 'System.Windows.Forms.Button'
	$textbox5 = New-Object 'System.Windows.Forms.TextBox'
	$labelLocationieJacksonWar = New-Object 'System.Windows.Forms.Label'
	$button2 = New-Object 'System.Windows.Forms.Button'
	$textbox4 = New-Object 'System.Windows.Forms.TextBox'
	$labelManager = New-Object 'System.Windows.Forms.Label'
	$button1 = New-Object 'System.Windows.Forms.Button'
	$textbox3 = New-Object 'System.Windows.Forms.TextBox'
	$labelDepartment = New-Object 'System.Windows.Forms.Label'
	$buttonSubmit = New-Object 'System.Windows.Forms.Button'
	$textbox2 = New-Object 'System.Windows.Forms.TextBox'
	$labelJobTitle = New-Object 'System.Windows.Forms.Label'
	$datagridview1 = New-Object 'System.Windows.Forms.DataGridView'
	$buttonSearch = New-Object 'System.Windows.Forms.Button'
	$textbox1 = New-Object 'System.Windows.Forms.TextBox'
	$labelUsername = New-Object 'System.Windows.Forms.Label'
	$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
	#endregion Generated Form Objects

	#----------------------------------------------
	# User Generated Script
	#----------------------------------------------
	
	
	
	
	
	
	
	$formHRUserEdit_Load={
		#TODO: Initialize Form Controls here
		#$statusbar1.Text = "Ready"
		$statusstrip1.items.add('Ready...')
	
	}
	
	$textbox1_TextChanged={
		#TODO: Place custom script here
		
	}
	
	$buttonSearch_Click={
		#TODO: Place custom script here
		
		$users = New-Object System.Collections.ArrayList
			if(!($textbox1.Text)) {
							$userinfo = Get-ADUser -ErrorAction Stop | select SAMAccountName,Name
						}
						else {
							$userinfo = Get-aduser $textbox1.Text -ErrorAction Stop | select SAMAccountName,Name
						}
						if($userinfo.count) {
							$users.addrange($userinfo)
						}
						else {
							$users.Add($userinfo)
						}
						
						$datagridview1.DataSource = $users
						$form1.refresh()
	
	}
	
	
	function Load-DataGridView
	{
		<#
		.SYNOPSIS
			This functions helps you load items into a DataGridView.
	
		.DESCRIPTION
			Use this function to dynamically load items into the DataGridView control.
	
		.PARAMETER  DataGridView
			The ComboBox control you want to add items to.
	
		.PARAMETER  Item
			The object or objects you wish to load into the ComboBox's items collection.
		
		.PARAMETER  DataMember
			Sets the name of the list or table in the data source for which the DataGridView is displaying data.
	
		#>
		Param (
			[ValidateNotNull()]
			[Parameter(Mandatory=$true)]
			[System.Windows.Forms.DataGridView]$DataGridView,
			[ValidateNotNull()]
			[Parameter(Mandatory=$true)]
			$Item,
		    [Parameter(Mandatory=$false)]
			[string]$DataMember
		)
		$DataGridView.SuspendLayout()
		$DataGridView.DataMember = $DataMember
		
		if ($Item -is [System.ComponentModel.IListSource]`
		-or $Item -is [System.ComponentModel.IBindingList] -or $Item -is [System.ComponentModel.IBindingListView] )
		{
			$DataGridView.DataSource = $Item
		}
		else
		{
			$array = New-Object System.Collections.ArrayList
			
			if ($Item -is [System.Collections.IList])
			{
				$array.AddRange($Item)
			}
			else
			{	
				$array.Add($Item)	
			}
			$DataGridView.DataSource = $array
		}
		
		$DataGridView.ResumeLayout()
	}
	#endregion
	
	$datagridview1_CellContentClick=[System.Windows.Forms.DataGridViewCellEventHandler]{
	#Event Argument: $_ = [System.Windows.Forms.DataGridViewCellEventArgs]
		#TODO: Place custom script here
		
	}
	
	$buttonSubmit_Click={
		#TODO: Place custom script here
		Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Description $textbox2.Text 
		Set-ADUser -identity $datagridview1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Title $textbox2.Text
		$statusstrip1.Items.Add('Job title changed...')
	}
	
	$textbox3_TextChanged={
		#TODO: Place custom script here
		
	}
	
	$button1_Click={
		#TODO: Place custom script here
		Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Department $textbox3.text
		$statusstrip1.Items.Add('Department changed...')
	}
	
	$textbox4_TextChanged={
		#TODO: Place custom script here
		
	}
	
	$button2_Click={
		#TODO: Place custom script here
		Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Manager $textbox4.Text
		$statusstrip1.Items.Add('Manager changed...')
	}
	
	$textbox5_TextChanged={
		#TODO: Place custom script here
		
	}
	
	$button3_Click={
		#TODO: Place custom script here
		#Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop - $textbox5.Text
		$location = $textbox5.Text
		if ($location -eq "Michigan") {Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -streetaddress "525 S. Coldwater Rd."; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -City "Weidman";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -State "MI";
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -PostalCode "48893"; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Office "Michigan"}
		if ($location -eq "Jackson") {Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -StreetAddress "1055 Mendell Davis Dr."; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -City "Jackson";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -State "MS";
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -PostalCode "39272";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Office "Jackson"}
		if ($location -eq "KC") {Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -StreetAddress "903 E. 104th St., Suite 130"; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -City "Kansas City";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -State "MO";
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -PostalCode "64131";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Office "Kansas City"}
		if ($location -eq "Pryor") {Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -StreetAddress "4650 54th St. MAIP bldg 601"; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -City "Pryor";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -State "OK";
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -PostalCode "74361";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Office "Pryor"}
		if ($location -eq "Warehouse") {Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -StreetAddress "123 Any street"; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -City "Jackson";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -State "MS";
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -PostalCode "39272";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Office "Warehouse"}
	
		$statusstrip1.Items.Add('Physical address changed...')
	
	}
	
	# --End User Generated Script--
	#----------------------------------------------
	#region Generated Events
	#----------------------------------------------
	
	$Form_StateCorrection_Load=
	{
		#Correct the initial state of the form to prevent the .Net maximized form issue
		$formHRUserEdit.WindowState = $InitialFormWindowState
	}
	
	$Form_Cleanup_FormClosed=
	{
		#Remove all event handlers from the controls
		try
		{
			$button3.remove_Click($button3_Click)
			$textbox5.remove_TextChanged($textbox5_TextChanged)
			$button2.remove_Click($button2_Click)
			$textbox4.remove_TextChanged($textbox4_TextChanged)
			$button1.remove_Click($button1_Click)
			$textbox3.remove_TextChanged($textbox3_TextChanged)
			$buttonSubmit.remove_Click($buttonSubmit_Click)
			$datagridview1.remove_CellContentClick($datagridview1_CellContentClick)
			$buttonSearch.remove_Click($buttonSearch_Click)
			$textbox1.remove_TextChanged($textbox1_TextChanged)
			$formHRUserEdit.remove_Load($formHRUserEdit_Load)
			$formHRUserEdit.remove_Load($Form_StateCorrection_Load)
			$formHRUserEdit.remove_FormClosed($Form_Cleanup_FormClosed)
		}
		catch [Exception]
		{ }
	}
	#endregion Generated Events

	#----------------------------------------------
	#region Generated Form Code
	#----------------------------------------------
	#
	# formHRUserEdit
	#
	$formHRUserEdit.Controls.Add($statusstrip1)
	$formHRUserEdit.Controls.Add($button3)
	$formHRUserEdit.Controls.Add($textbox5)
	$formHRUserEdit.Controls.Add($labelLocationieJacksonWar)
	$formHRUserEdit.Controls.Add($button2)
	$formHRUserEdit.Controls.Add($textbox4)
	$formHRUserEdit.Controls.Add($labelManager)
	$formHRUserEdit.Controls.Add($button1)
	$formHRUserEdit.Controls.Add($textbox3)
	$formHRUserEdit.Controls.Add($labelDepartment)
	$formHRUserEdit.Controls.Add($buttonSubmit)
	$formHRUserEdit.Controls.Add($textbox2)
	$formHRUserEdit.Controls.Add($labelJobTitle)
	$formHRUserEdit.Controls.Add($datagridview1)
	$formHRUserEdit.Controls.Add($buttonSearch)
	$formHRUserEdit.Controls.Add($textbox1)
	$formHRUserEdit.Controls.Add($labelUsername)
	$formHRUserEdit.ClientSize = '340, 373'
	$formHRUserEdit.Name = "formHRUserEdit"
	$formHRUserEdit.Text = "HR - User Edit"
	$formHRUserEdit.add_Load($formHRUserEdit_Load)
	#
	# statusstrip1
	#
	$statusstrip1.AutoSize = $False
	$statusstrip1.LayoutStyle = 'Flow'
	$statusstrip1.Location = '0, 309'
	$statusstrip1.Name = "statusstrip1"
	$statusstrip1.Size = '340, 64'
	$statusstrip1.TabIndex = 16
	#
	# button3
	#
	$button3.Location = '231, 269'
	$button3.Name = "button3"
	$button3.Size = '75, 23'
	$button3.TabIndex = 15
	$button3.Text = "Submit"
	$button3.UseVisualStyleBackColor = $True
	$button3.add_Click($button3_Click)
	#
	# textbox5
	#
	$textbox5.Location = '13, 269'
	$textbox5.Name = "textbox5"
	$textbox5.Size = '199, 20'
	$textbox5.TabIndex = 14
	$textbox5.add_TextChanged($textbox5_TextChanged)
	#
	# labelLocationieJacksonWar
	#
	$labelLocationieJacksonWar.Location = '13, 251'
	$labelLocationieJacksonWar.Name = "labelLocationieJacksonWar"
	$labelLocationieJacksonWar.Size = '277, 14'
	$labelLocationieJacksonWar.TabIndex = 13
	$labelLocationieJacksonWar.Text = "Location (i.e. Jackson, Warehouse, Michigan, KC, Pryor)"
	#
	# button2
	#
	$button2.Location = '231, 224'
	$button2.Name = "button2"
	$button2.Size = '75, 23'
	$button2.TabIndex = 12
	$button2.Text = "Submit"
	$button2.UseVisualStyleBackColor = $True
	$button2.add_Click($button2_Click)
	#
	# textbox4
	#
	$textbox4.Location = '13, 224'
	$textbox4.Name = "textbox4"
	$textbox4.Size = '199, 20'
	$textbox4.TabIndex = 11
	$textbox4.add_TextChanged($textbox4_TextChanged)
	#
	# labelManager
	#
	$labelManager.Location = '13, 204'
	$labelManager.Name = "labelManager"
	$labelManager.Size = '100, 16'
	$labelManager.TabIndex = 10
	$labelManager.Text = "Manager"
	#
	# button1
	#
	$button1.Location = '231, 177'
	$button1.Name = "button1"
	$button1.Size = '75, 23'
	$button1.TabIndex = 9
	$button1.Text = "Submit"
	$button1.UseVisualStyleBackColor = $True
	$button1.add_Click($button1_Click)
	#
	# textbox3
	#
	$textbox3.Location = '13, 177'
	$textbox3.Name = "textbox3"
	$textbox3.Size = '199, 20'
	$textbox3.TabIndex = 8
	$textbox3.add_TextChanged($textbox3_TextChanged)
	#
	# labelDepartment
	#
	$labelDepartment.Location = '13, 156'
	$labelDepartment.Name = "labelDepartment"
	$labelDepartment.Size = '100, 17'
	$labelDepartment.TabIndex = 7
	$labelDepartment.Text = "Department"
	#
	# buttonSubmit
	#
	$buttonSubmit.Location = '231, 129'
	$buttonSubmit.Name = "buttonSubmit"
	$buttonSubmit.Size = '75, 23'
	$buttonSubmit.TabIndex = 6
	$buttonSubmit.Text = "Submit"
	$buttonSubmit.UseVisualStyleBackColor = $True
	$buttonSubmit.add_Click($buttonSubmit_Click)
	#
	# textbox2
	#
	$textbox2.Location = '13, 129'
	$textbox2.Name = "textbox2"
	$textbox2.Size = '199, 20'
	$textbox2.TabIndex = 5
	#
	# labelJobTitle
	#
	$labelJobTitle.Location = '13, 108'
	$labelJobTitle.Name = "labelJobTitle"
	$labelJobTitle.Size = '100, 17'
	$labelJobTitle.TabIndex = 4
	$labelJobTitle.Text = "Job Title"
	#
	# datagridview1
	#
	$datagridview1.AllowUserToDeleteRows = $False
	$System_Windows_Forms_DataGridViewCellStyle_1 = New-Object 'System.Windows.Forms.DataGridViewCellStyle'
	$System_Windows_Forms_DataGridViewCellStyle_1.Alignment = 'MiddleLeft'
	$System_Windows_Forms_DataGridViewCellStyle_1.BackColor = 'Control'
	$System_Windows_Forms_DataGridViewCellStyle_1.Font = "Microsoft Sans Serif, 8.25pt"
	$System_Windows_Forms_DataGridViewCellStyle_1.ForeColor = 'WindowText'
	$System_Windows_Forms_DataGridViewCellStyle_1.SelectionBackColor = 'Highlight'
	$System_Windows_Forms_DataGridViewCellStyle_1.SelectionForeColor = 'HighlightText'
	$System_Windows_Forms_DataGridViewCellStyle_1.WrapMode = 'True'
	$datagridview1.ColumnHeadersDefaultCellStyle = $System_Windows_Forms_DataGridViewCellStyle_1
	$datagridview1.ColumnHeadersVisible = $False
	$System_Windows_Forms_DataGridViewCellStyle_2 = New-Object 'System.Windows.Forms.DataGridViewCellStyle'
	$System_Windows_Forms_DataGridViewCellStyle_2.Alignment = 'MiddleLeft'
	$System_Windows_Forms_DataGridViewCellStyle_2.BackColor = 'Window'
	$System_Windows_Forms_DataGridViewCellStyle_2.Font = "Microsoft Sans Serif, 8.25pt"
	$System_Windows_Forms_DataGridViewCellStyle_2.ForeColor = 'ControlText'
	$System_Windows_Forms_DataGridViewCellStyle_2.SelectionBackColor = 'Highlight'
	$System_Windows_Forms_DataGridViewCellStyle_2.SelectionForeColor = 'HighlightText'
	$System_Windows_Forms_DataGridViewCellStyle_2.WrapMode = 'False'
	$datagridview1.DefaultCellStyle = $System_Windows_Forms_DataGridViewCellStyle_2
	$datagridview1.Location = '13, 57'
	$datagridview1.Name = "datagridview1"
	$System_Windows_Forms_DataGridViewCellStyle_3 = New-Object 'System.Windows.Forms.DataGridViewCellStyle'
	$System_Windows_Forms_DataGridViewCellStyle_3.Alignment = 'MiddleLeft'
	$System_Windows_Forms_DataGridViewCellStyle_3.BackColor = 'Control'
	$System_Windows_Forms_DataGridViewCellStyle_3.Font = "Microsoft Sans Serif, 8.25pt"
	$System_Windows_Forms_DataGridViewCellStyle_3.ForeColor = 'WindowText'
	$System_Windows_Forms_DataGridViewCellStyle_3.SelectionBackColor = 'Highlight'
	$System_Windows_Forms_DataGridViewCellStyle_3.SelectionForeColor = 'HighlightText'
	$System_Windows_Forms_DataGridViewCellStyle_3.WrapMode = 'True'
	$datagridview1.RowHeadersDefaultCellStyle = $System_Windows_Forms_DataGridViewCellStyle_3
	$datagridview1.Size = '305, 48'
	$datagridview1.TabIndex = 3
	$datagridview1.TabStop = $False
	$datagridview1.add_CellContentClick($datagridview1_CellContentClick)
	#
	# buttonSearch
	#
	$buttonSearch.Location = '201, 30'
	$buttonSearch.Name = "buttonSearch"
	$buttonSearch.Size = '75, 23'
	$buttonSearch.TabIndex = 2
	$buttonSearch.Text = "Search"
	$buttonSearch.UseVisualStyleBackColor = $True
	$buttonSearch.add_Click($buttonSearch_Click)
	#
	# textbox1
	#
	$textbox1.Location = '13, 30'
	$textbox1.Name = "textbox1"
	$textbox1.Size = '181, 20'
	$textbox1.TabIndex = 1
	$textbox1.add_TextChanged($textbox1_TextChanged)
	#
	# labelUsername
	#
	$labelUsername.Location = '13, 13'
	$labelUsername.Name = "labelUsername"
	$labelUsername.Size = '100, 13'
	$labelUsername.TabIndex = 0
	$labelUsername.Text = "Username"
	#endregion Generated Form Code

	#----------------------------------------------

	#Save the initial state of the form
	$InitialFormWindowState = $formHRUserEdit.WindowState
	#Init the OnLoad event to correct the initial state of the form
	$formHRUserEdit.add_Load($Form_StateCorrection_Load)
	#Clean up the control events
	$formHRUserEdit.add_FormClosed($Form_Cleanup_FormClosed)
	#Show the Form
	return $formHRUserEdit.ShowDialog()

} #End Function

#Call OnApplicationLoad to initialize
if((OnApplicationLoad) -eq $true)
{
	#Call the form
	Call-HR_User_Change_pff | Out-Null
	#Perform cleanup
	OnApplicationExit
}

Open in new window


What I've got is a form with textboxes for Username, Department, Job Title, Manager and Location.  Username must be in the form of SAMAccountName, likewise with Manager.  So I'd like for any errors arising from a person inputing an invalid or non-existent username to be caught and displayed in Statusstrip1.

Thanks!
0
Comment
Question by:Ben Hart
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Expert Comment

by:Joe Klimis
ID: 39945566
Hi

At what point would you like is to check  ?   when they leave the text box , or on a button prerss ?

Joe
0
 
LVL 14

Author Comment

by:Ben Hart
ID: 39945573
Originally I though on button_click.. but if something like an incorrect or invalid username would be caught after typing the last character before clicking the button that'd be awesome
0
 
LVL 11

Accepted Solution

by:
Joe Klimis earned 2000 total points
ID: 39947386
Hi

Please see below

I have added the validation , so until a valid username is entered you are unable to search
this also populates the fields with the current values.

I hope this is what you were looking for.



#------------------------------------------------------------------------
#========================================================================
# Code Generated By: SAPIEN Technologies, Inc., PowerShell Studio 2012 v3.1.26
# Generated On: 3/21/2014 11:27 AM
# Generated By: bhart
#========================================================================
#----------------------------------------------
#region Application Functions
#----------------------------------------------

function OnApplicationLoad {
	#Note: This function is not called in Projects
	#Note: This function runs before the form is created
	#Note: To get the script directory in the Packager use: Split-Path $hostinvocation.MyCommand.path
	#Note: To get the console output in the Packager (Windows Mode) use: $ConsoleOutput (Type: System.Collections.ArrayList)
	#Important: Form controls cannot be accessed in this function
	#TODO: Add snapins and custom code to validate the application load
	Import-Module ActiveDirectory
	
	return $true #return true for success or false for failure
}

function OnApplicationExit {
	#Note: This function is not called in Projects
	#Note: This function runs after the form is closed
	#TODO: Add custom code to clean up and unload snapins when the application exits
	
	$script:ExitCode = 0 #Set the exit code for the Packager
}

#endregion Application Functions

#----------------------------------------------
# Generated Form Function
#----------------------------------------------
function Call-HR_User_Change_pff {

	#----------------------------------------------
	#region Import the Assemblies
	#----------------------------------------------
	[void][reflection.assembly]::Load("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
	[void][reflection.assembly]::Load("System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
	[void][reflection.assembly]::Load("System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
	[void][reflection.assembly]::Load("System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
	#endregion Import Assemblies

	#----------------------------------------------
	#region Generated Form Objects
	#----------------------------------------------
	[System.Windows.Forms.Application]::EnableVisualStyles()
	$formHRUserEdit = New-Object 'System.Windows.Forms.Form'
	$statusstrip1 = New-Object 'System.Windows.Forms.StatusStrip'
	$button3 = New-Object 'System.Windows.Forms.Button'
	$textbox5 = New-Object 'System.Windows.Forms.TextBox'
	$labelLocationieJacksonWar = New-Object 'System.Windows.Forms.Label'
	$button2 = New-Object 'System.Windows.Forms.Button'
	$textbox4 = New-Object 'System.Windows.Forms.TextBox'
	$labelManager = New-Object 'System.Windows.Forms.Label'
	$button1 = New-Object 'System.Windows.Forms.Button'
	$textbox3 = New-Object 'System.Windows.Forms.TextBox'
	$labelDepartment = New-Object 'System.Windows.Forms.Label'
	$buttonSubmit = New-Object 'System.Windows.Forms.Button'
	$textbox2 = New-Object 'System.Windows.Forms.TextBox'
	$labelJobTitle = New-Object 'System.Windows.Forms.Label'
	$datagridview1 = New-Object 'System.Windows.Forms.DataGridView'
	$buttonSearch = New-Object 'System.Windows.Forms.Button'
	$textbox1 = New-Object 'System.Windows.Forms.TextBox'
	$labelUsername = New-Object 'System.Windows.Forms.Label'
	$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
	#endregion Generated Form Objects

	#----------------------------------------------
	# User Generated Script
	#----------------------------------------------
	
	
	
	
	
	
	
	$formHRUserEdit_Load={
		#TODO: Initialize Form Controls here
		#$statusbar1.Text = "Ready"
		$statusstrip1.items.add('Ready...')
	$buttonSearch.enabled = $false
	
	}
	
	$textbox1_TextChanged=
	{
	$buttonSearch.enabled = $false
	$statusstrip1.items.clear()
	$user = $(try {Get-ADUser $textbox1.Text} catch {$null})
	if ($user -ne $null) {  # valid user
		$statusstrip1.items.add("Valid User $($textbox1.Text)...")
		$buttonSearch.enabled = $true  # enable search

	} 
	else {  $statusstrip1.items.add('Username invalid...')}
				
		
	}
	
	$buttonSearch_Click={
		#TODO: Place custom script here
		
		$users = New-Object System.Collections.ArrayList
				$userInfoDetail = Get-aduser  $textbox1.Text -ErrorAction Stop -property SAMAccountName,Name,title,description,department,manager,city
				$userinfo = $userInfoDetail | select SAMAccountName,Name
						
		if($userinfo.count) {			$users.addrange($userinfo)			}
						else { 			$users.Add($userinfo)				}
						
						$textbox2.Text = $userinfodetail.title
						$textbox3.text =  $userinfodetail.department
						if ($textbox4.text -ne "") {$textbox4.text =  $userInfoDetail.manager.split(",")[0].split("=")[1]}
						else {$textbox4.text = ""}
						$textbox5.text =   $userinfodetail.City
						$datagridview1.DataSource = $users
						$formHRUserEdit.refresh()
	
	}
	
	
	function Load-DataGridView
	{
		<#
		.SYNOPSIS
			This functions helps you load items into a DataGridView.
	
		.DESCRIPTION
			Use this function to dynamically load items into the DataGridView control.
	
		.PARAMETER  DataGridView
			The ComboBox control you want to add items to.
	
		.PARAMETER  Item
			The object or objects you wish to load into the ComboBox's items collection.
		
		.PARAMETER  DataMember
			Sets the name of the list or table in the data source for which the DataGridView is displaying data.
	
		#>
		Param (
			[ValidateNotNull()]
			[Parameter(Mandatory=$true)]
			[System.Windows.Forms.DataGridView]$DataGridView,
			[ValidateNotNull()]
			[Parameter(Mandatory=$true)]
			$Item,
		    [Parameter(Mandatory=$false)]
			[string]$DataMember
		)
		$DataGridView.SuspendLayout()
		$DataGridView.DataMember = $DataMember
		
		if ($Item -is [System.ComponentModel.IListSource]`
		-or $Item -is [System.ComponentModel.IBindingList] -or $Item -is [System.ComponentModel.IBindingListView] )
		{
			$DataGridView.DataSource = $Item
		}
		else
		{
			$array = New-Object System.Collections.ArrayList
			
			if ($Item -is [System.Collections.IList])
			{
				$array.AddRange($Item)
			}
			else
			{	
				$array.Add($Item)	
			}
			$DataGridView.DataSource = $array
		}
		
		$DataGridView.ResumeLayout()
	}
	#endregion
	
	$datagridview1_CellContentClick=[System.Windows.Forms.DataGridViewCellEventHandler]{
	#Event Argument: $_ = [System.Windows.Forms.DataGridViewCellEventArgs]
		#TODO: Place custom script here
		
	}
	
	$buttonSubmit_Click={
		#TODO: Place custom script here
		Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Description $textbox2.Text 
		Set-ADUser -identity $datagridview1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Title $textbox2.Text
		$statusstrip1.Items.Add('Job title changed...')
	}
	
	$textbox3_TextChanged={
		#TODO: Place custom script here
		
	}
	
	$button1_Click={
		#TODO: Place custom script here
		Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Department $textbox3.text
		$statusstrip1.Items.Add('Department changed...')
	}
	
	$textbox4_TextChanged={
		#TODO: Place custom script here
		
	}
	
	$button2_Click={
		#TODO: Place custom script here
		Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Manager $textbox4.Text
		$statusstrip1.Items.Add('Manager changed...')
	}
	
	$textbox5_TextChanged={
		#TODO: Place custom script here
		
	}
	
	$button3_Click={
		#TODO: Place custom script here
		#Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop - $textbox5.Text
		$location = $textbox5.Text
		if ($location -eq "Michigan") {Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -streetaddress "525 S. Coldwater Rd."; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -City "Weidman";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -State "MI";
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -PostalCode "48893"; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Office "Michigan"}
		if ($location -eq "Jackson") {Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -StreetAddress "1055 Mendell Davis Dr."; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -City "Jackson";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -State "MS";
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -PostalCode "39272";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Office "Jackson"}
		if ($location -eq "KC") {Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -StreetAddress "903 E. 104th St., Suite 130"; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -City "Kansas City";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -State "MO";
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -PostalCode "64131";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Office "Kansas City"}
		if ($location -eq "Pryor") {Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -StreetAddress "4650 54th St. MAIP bldg 601"; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -City "Pryor";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -State "OK";
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -PostalCode "74361";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Office "Pryor"}
		if ($location -eq "Warehouse") {Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -StreetAddress "123 Any street"; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -City "Jackson";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -State "MS";
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -PostalCode "39272";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Office "Warehouse"}
	
		$statusstrip1.Items.Add('Physical address changed...')
	
	}
	
	# --End User Generated Script--
	#----------------------------------------------
	#region Generated Events
	#----------------------------------------------
	
	$Form_StateCorrection_Load=
	{
		#Correct the initial state of the form to prevent the .Net maximized form issue
		$formHRUserEdit.WindowState = $InitialFormWindowState
	}
	
	$Form_Cleanup_FormClosed=
	{
		#Remove all event handlers from the controls
		try
		{
			$button3.remove_Click($button3_Click)
			$textbox5.remove_TextChanged($textbox5_TextChanged)
			$button2.remove_Click($button2_Click)
			$textbox4.remove_TextChanged($textbox4_TextChanged)
			$button1.remove_Click($button1_Click)
			$textbox3.remove_TextChanged($textbox3_TextChanged)
			$buttonSubmit.remove_Click($buttonSubmit_Click)
			$datagridview1.remove_CellContentClick($datagridview1_CellContentClick)
			$buttonSearch.remove_Click($buttonSearch_Click)
			$textbox1.remove_TextChanged($textbox1_TextChanged)
			$formHRUserEdit.remove_Load($formHRUserEdit_Load)
			$formHRUserEdit.remove_Load($Form_StateCorrection_Load)
			$formHRUserEdit.remove_FormClosed($Form_Cleanup_FormClosed)
		}
		catch [Exception]
		{ }
	}
	#endregion Generated Events

	#----------------------------------------------
	#region Generated Form Code
	#----------------------------------------------
	#
	# formHRUserEdit
	#
	$formHRUserEdit.Controls.Add($statusstrip1)
	$formHRUserEdit.Controls.Add($button3)
	$formHRUserEdit.Controls.Add($textbox5)
	$formHRUserEdit.Controls.Add($labelLocationieJacksonWar)
	$formHRUserEdit.Controls.Add($button2)
	$formHRUserEdit.Controls.Add($textbox4)
	$formHRUserEdit.Controls.Add($labelManager)
	$formHRUserEdit.Controls.Add($button1)
	$formHRUserEdit.Controls.Add($textbox3)
	$formHRUserEdit.Controls.Add($labelDepartment)
	$formHRUserEdit.Controls.Add($buttonSubmit)
	$formHRUserEdit.Controls.Add($textbox2)
	$formHRUserEdit.Controls.Add($labelJobTitle)
	$formHRUserEdit.Controls.Add($datagridview1)
	$formHRUserEdit.Controls.Add($buttonSearch)
	$formHRUserEdit.Controls.Add($textbox1)
	$formHRUserEdit.Controls.Add($labelUsername)
	$formHRUserEdit.ClientSize = '340, 373'
	$formHRUserEdit.Name = "formHRUserEdit"
	$formHRUserEdit.Text = "HR - User Edit"
	$formHRUserEdit.add_Load($formHRUserEdit_Load)
	#
	# statusstrip1
	#
	$statusstrip1.AutoSize = $False
	$statusstrip1.LayoutStyle = 'Flow'
	$statusstrip1.Location = '0, 309'
	$statusstrip1.Name = "statusstrip1"
	$statusstrip1.Size = '340, 64'
	$statusstrip1.TabIndex = 16
	#
	# button3
	#
	$button3.Location = '231, 269'
	$button3.Name = "button3"
	$button3.Size = '75, 23'
	$button3.TabIndex = 15
	$button3.Text = "Submit"
	$button3.UseVisualStyleBackColor = $True
	$button3.add_Click($button3_Click)
	#
	# textbox5
	#
	$textbox5.Location = '13, 269'
	$textbox5.Name = "textbox5"
	$textbox5.Size = '199, 20'
	$textbox5.TabIndex = 14
	$textbox5.add_TextChanged($textbox5_TextChanged)
	#
	# labelLocationieJacksonWar
	#
	$labelLocationieJacksonWar.Location = '13, 251'
	$labelLocationieJacksonWar.Name = "labelLocationieJacksonWar"
	$labelLocationieJacksonWar.Size = '277, 14'
	$labelLocationieJacksonWar.TabIndex = 13
	$labelLocationieJacksonWar.Text = "Location (i.e. Jackson, Warehouse, Michigan, KC, Pryor)"
	#
	# button2
	#
	$button2.Location = '231, 224'
	$button2.Name = "button2"
	$button2.Size = '75, 23'
	$button2.TabIndex = 12
	$button2.Text = "Submit"
	$button2.UseVisualStyleBackColor = $True
	$button2.add_Click($button2_Click)
	#
	# textbox4
	#
	$textbox4.Location = '13, 224'
	$textbox4.Name = "textbox4"
	$textbox4.Size = '199, 20'
	$textbox4.TabIndex = 11
	$textbox4.add_TextChanged($textbox4_TextChanged)
	#
	# labelManager
	#
	$labelManager.Location = '13, 204'
	$labelManager.Name = "labelManager"
	$labelManager.Size = '100, 16'
	$labelManager.TabIndex = 10
	$labelManager.Text = "Manager"
	#
	# button1
	#
	$button1.Location = '231, 177'
	$button1.Name = "button1"
	$button1.Size = '75, 23'
	$button1.TabIndex = 9
	$button1.Text = "Submit"
	$button1.UseVisualStyleBackColor = $True
	$button1.add_Click($button1_Click)
	#
	# textbox3
	#
	$textbox3.Location = '13, 177'
	$textbox3.Name = "textbox3"
	$textbox3.Size = '199, 20'
	$textbox3.TabIndex = 8
	$textbox3.add_TextChanged($textbox3_TextChanged)
	#
	# labelDepartment
	#
	$labelDepartment.Location = '13, 156'
	$labelDepartment.Name = "labelDepartment"
	$labelDepartment.Size = '100, 17'
	$labelDepartment.TabIndex = 7
	$labelDepartment.Text = "Department"
	#
	# buttonSubmit
	#
	$buttonSubmit.Location = '231, 129'
	$buttonSubmit.Name = "buttonSubmit"
	$buttonSubmit.Size = '75, 23'
	$buttonSubmit.TabIndex = 6
	$buttonSubmit.Text = "Submit"
	$buttonSubmit.UseVisualStyleBackColor = $True
	$buttonSubmit.add_Click($buttonSubmit_Click)
	#
	# textbox2
	#
	$textbox2.Location = '13, 129'
	$textbox2.Name = "textbox2"
	$textbox2.Size = '199, 20'
	$textbox2.TabIndex = 5
	#
	# labelJobTitle
	#
	$labelJobTitle.Location = '13, 108'
	$labelJobTitle.Name = "labelJobTitle"
	$labelJobTitle.Size = '100, 17'
	$labelJobTitle.TabIndex = 4
	$labelJobTitle.Text = "Job Title"
	#
	# datagridview1
	#
	$datagridview1.AllowUserToDeleteRows = $False
	$System_Windows_Forms_DataGridViewCellStyle_1 = New-Object 'System.Windows.Forms.DataGridViewCellStyle'
	$System_Windows_Forms_DataGridViewCellStyle_1.Alignment = 'MiddleLeft'
	$System_Windows_Forms_DataGridViewCellStyle_1.BackColor = 'Control'
	$System_Windows_Forms_DataGridViewCellStyle_1.Font = "Microsoft Sans Serif, 8.25pt"
	$System_Windows_Forms_DataGridViewCellStyle_1.ForeColor = 'WindowText'
	$System_Windows_Forms_DataGridViewCellStyle_1.SelectionBackColor = 'Highlight'
	$System_Windows_Forms_DataGridViewCellStyle_1.SelectionForeColor = 'HighlightText'
	$System_Windows_Forms_DataGridViewCellStyle_1.WrapMode = 'True'
	$datagridview1.ColumnHeadersDefaultCellStyle = $System_Windows_Forms_DataGridViewCellStyle_1
	$datagridview1.ColumnHeadersVisible = $False
	$System_Windows_Forms_DataGridViewCellStyle_2 = New-Object 'System.Windows.Forms.DataGridViewCellStyle'
	$System_Windows_Forms_DataGridViewCellStyle_2.Alignment = 'MiddleLeft'
	$System_Windows_Forms_DataGridViewCellStyle_2.BackColor = 'Window'
	$System_Windows_Forms_DataGridViewCellStyle_2.Font = "Microsoft Sans Serif, 8.25pt"
	$System_Windows_Forms_DataGridViewCellStyle_2.ForeColor = 'ControlText'
	$System_Windows_Forms_DataGridViewCellStyle_2.SelectionBackColor = 'Highlight'
	$System_Windows_Forms_DataGridViewCellStyle_2.SelectionForeColor = 'HighlightText'
	$System_Windows_Forms_DataGridViewCellStyle_2.WrapMode = 'False'
	$datagridview1.DefaultCellStyle = $System_Windows_Forms_DataGridViewCellStyle_2
	$datagridview1.Location = '13, 57'
	$datagridview1.Name = "datagridview1"
	$System_Windows_Forms_DataGridViewCellStyle_3 = New-Object 'System.Windows.Forms.DataGridViewCellStyle'
	$System_Windows_Forms_DataGridViewCellStyle_3.Alignment = 'MiddleLeft'
	$System_Windows_Forms_DataGridViewCellStyle_3.BackColor = 'Control'
	$System_Windows_Forms_DataGridViewCellStyle_3.Font = "Microsoft Sans Serif, 8.25pt"
	$System_Windows_Forms_DataGridViewCellStyle_3.ForeColor = 'WindowText'
	$System_Windows_Forms_DataGridViewCellStyle_3.SelectionBackColor = 'Highlight'
	$System_Windows_Forms_DataGridViewCellStyle_3.SelectionForeColor = 'HighlightText'
	$System_Windows_Forms_DataGridViewCellStyle_3.WrapMode = 'True'
	$datagridview1.RowHeadersDefaultCellStyle = $System_Windows_Forms_DataGridViewCellStyle_3
	$datagridview1.Size = '305, 48'
	$datagridview1.TabIndex = 3
	$datagridview1.TabStop = $False
	$datagridview1.add_CellContentClick($datagridview1_CellContentClick)
	#
	# buttonSearch
	#
	$buttonSearch.Location = '201, 30'
	$buttonSearch.Name = "buttonSearch"
	$buttonSearch.Size = '75, 23'
	$buttonSearch.TabIndex = 2
	$buttonSearch.Text = "Search"
	$buttonSearch.UseVisualStyleBackColor = $True
	$buttonSearch.add_Click($buttonSearch_Click)
	#
	# textbox1
	#
	$textbox1.Location = '13, 30'
	$textbox1.Name = "textbox1"
	$textbox1.Size = '181, 20'
	$textbox1.TabIndex = 1
	$textbox1.add_TextChanged($textbox1_TextChanged)
	#
	# labelUsername
	#
	$labelUsername.Location = '13, 13'
	$labelUsername.Name = "labelUsername"
	$labelUsername.Size = '100, 13'
	$labelUsername.TabIndex = 0
	$labelUsername.Text = "Username"
	#endregion Generated Form Code

	#----------------------------------------------

	#Save the initial state of the form
	$InitialFormWindowState = $formHRUserEdit.WindowState
	#Init the OnLoad event to correct the initial state of the form
	$formHRUserEdit.add_Load($Form_StateCorrection_Load)
	#Clean up the control events
	$formHRUserEdit.add_FormClosed($Form_Cleanup_FormClosed)
	#Show the Form
	return $formHRUserEdit.ShowDialog()

} #End Function

#Call OnApplicationLoad to initialize
if((OnApplicationLoad) -eq $true)
{
	#Call the form
	Call-HR_User_Change_pff | Out-Null
	#Perform cleanup
	OnApplicationExit
}#------------------------------------------------------------------------
# 
#========================================================================
# Code Generated By: SAPIEN Technologies, Inc., PowerShell Studio 2012 v3.1.26
# Generated On: 3/21/2014 11:27 AM
# Generated By: bhart
#========================================================================
#----------------------------------------------
#region Application Functions
#----------------------------------------------

function OnApplicationLoad {
	#Note: This function is not called in Projects
	#Note: This function runs before the form is created
	#Note: To get the script directory in the Packager use: Split-Path $hostinvocation.MyCommand.path
	#Note: To get the console output in the Packager (Windows Mode) use: $ConsoleOutput (Type: System.Collections.ArrayList)
	#Important: Form controls cannot be accessed in this function
	#TODO: Add snapins and custom code to validate the application load
	Import-Module ActiveDirectory
	
	return $true #return true for success or false for failure
}

function OnApplicationExit {
	#Note: This function is not called in Projects
	#Note: This function runs after the form is closed
	#TODO: Add custom code to clean up and unload snapins when the application exits
	
	$script:ExitCode = 0 #Set the exit code for the Packager
}

#endregion Application Functions

#----------------------------------------------
# Generated Form Function
#----------------------------------------------
function Call-HR_User_Change_pff {

	#----------------------------------------------
	#region Import the Assemblies
	#----------------------------------------------
	[void][reflection.assembly]::Load("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
	[void][reflection.assembly]::Load("System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
	[void][reflection.assembly]::Load("System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
	[void][reflection.assembly]::Load("System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
	#endregion Import Assemblies

	#----------------------------------------------
	#region Generated Form Objects
	#----------------------------------------------
	[System.Windows.Forms.Application]::EnableVisualStyles()
	$formHRUserEdit = New-Object 'System.Windows.Forms.Form'
	$statusstrip1 = New-Object 'System.Windows.Forms.StatusStrip'
	$button3 = New-Object 'System.Windows.Forms.Button'
	$textbox5 = New-Object 'System.Windows.Forms.TextBox'
	$labelLocationieJacksonWar = New-Object 'System.Windows.Forms.Label'
	$button2 = New-Object 'System.Windows.Forms.Button'
	$textbox4 = New-Object 'System.Windows.Forms.TextBox'
	$labelManager = New-Object 'System.Windows.Forms.Label'
	$button1 = New-Object 'System.Windows.Forms.Button'
	$textbox3 = New-Object 'System.Windows.Forms.TextBox'
	$labelDepartment = New-Object 'System.Windows.Forms.Label'
	$buttonSubmit = New-Object 'System.Windows.Forms.Button'
	$textbox2 = New-Object 'System.Windows.Forms.TextBox'
	$labelJobTitle = New-Object 'System.Windows.Forms.Label'
	$datagridview1 = New-Object 'System.Windows.Forms.DataGridView'
	$buttonSearch = New-Object 'System.Windows.Forms.Button'
	$textbox1 = New-Object 'System.Windows.Forms.TextBox'
	$labelUsername = New-Object 'System.Windows.Forms.Label'
	$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
	#endregion Generated Form Objects

	#----------------------------------------------
	# User Generated Script
	#----------------------------------------------
	
	
	
	
	
	
	
	$formHRUserEdit_Load={
		#TODO: Initialize Form Controls here
		#$statusbar1.Text = "Ready"
		$statusstrip1.items.add('Ready...')
	$buttonSearch.enabled = $false
	
	}
	
	$textbox1_TextChanged=
	{
	$buttonSearch.enabled = $false

	$statusstrip1.items.clear()
	$user = $(try {Get-ADUser $textbox1.Text} catch {$null})
	if ($user -ne $null) {  # valid user
		$statusstrip1.items.add("Valid User $($textbox1.Text)...")
		$buttonSearch.enabled = $true  # enable search

	} 
	else {  $statusstrip1.items.add('Username invalid...')}
				
		
	}
	
	$buttonSearch_Click={
		#TODO: Place custom script here
		
		$users = New-Object System.Collections.ArrayList
				$userInfoDetail = Get-aduser  $textbox1.Text -ErrorAction Stop -property SAMAccountName,Name,title,description,department,manager,city
				$userinfo = $userInfoDetail | select SAMAccountName,Name
						
		if($userinfo.count) {			$users.addrange($userinfo)			}
						else { 			$users.Add($userinfo)				}
						
						$textbox2.Text = $userinfodetail.title
						$textbox3.text =  $userinfodetail.department
						if ($userInfoDetail.manager -ne $null -and $userInfoDetail.manager -ne "") {$textbox4.text =  $userInfoDetail.manager.split(",")[0].split("=")[1]}
						$textbox4.text = $null
						$textbox5.text =   $userinfodetail.City
						$datagridview1.DataSource = $users
						$formHRUserEdit.refresh()
	
	}
	
	
	function Load-DataGridView
	{
		<#
		.SYNOPSIS
			This functions helps you load items into a DataGridView.
	
		.DESCRIPTION
			Use this function to dynamically load items into the DataGridView control.
	
		.PARAMETER  DataGridView
			The ComboBox control you want to add items to.
	
		.PARAMETER  Item
			The object or objects you wish to load into the ComboBox's items collection.
		
		.PARAMETER  DataMember
			Sets the name of the list or table in the data source for which the DataGridView is displaying data.
	
		#>
		Param (
			[ValidateNotNull()]
			[Parameter(Mandatory=$true)]
			[System.Windows.Forms.DataGridView]$DataGridView,
			[ValidateNotNull()]
			[Parameter(Mandatory=$true)]
			$Item,
		    [Parameter(Mandatory=$false)]
			[string]$DataMember
		)
		$DataGridView.SuspendLayout()
		$DataGridView.DataMember = $DataMember
		
		if ($Item -is [System.ComponentModel.IListSource]`
		-or $Item -is [System.ComponentModel.IBindingList] -or $Item -is [System.ComponentModel.IBindingListView] )
		{
			$DataGridView.DataSource = $Item
		}
		else
		{
			$array = New-Object System.Collections.ArrayList
			
			if ($Item -is [System.Collections.IList])
			{
				$array.AddRange($Item)
			}
			else
			{	
				$array.Add($Item)	
			}
			$DataGridView.DataSource = $array
		}
		
		$DataGridView.ResumeLayout()
	}
	#endregion
	
	$datagridview1_CellContentClick=[System.Windows.Forms.DataGridViewCellEventHandler]{
	#Event Argument: $_ = [System.Windows.Forms.DataGridViewCellEventArgs]
		#TODO: Place custom script here
		
	}
	
	$buttonSubmit_Click={
		#TODO: Place custom script here
		Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Description $textbox2.Text 
		Set-ADUser -identity $datagridview1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Title $textbox2.Text
		$statusstrip1.Items.Add('Job title changed...')
	}
	
	$textbox3_TextChanged={
		#TODO: Place custom script here
		
	}
	
	$button1_Click={
		#TODO: Place custom script here
		Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Department $textbox3.text
		$statusstrip1.Items.Add('Department changed...')
	}
	
	$textbox4_TextChanged={
		#TODO: Place custom script here
		
	}
	
	$button2_Click={
		#TODO: Place custom script here
		Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Manager $textbox4.Text
		$statusstrip1.Items.Add('Manager changed...')
	}
	
	$textbox5_TextChanged={
		#TODO: Place custom script here
		
	}
	
	$button3_Click={
		#TODO: Place custom script here
		#Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop - $textbox5.Text
		$location = $textbox5.Text
		if ($location -eq "Michigan") {Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -streetaddress "525 S. Coldwater Rd."; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -City "Weidman";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -State "MI";
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -PostalCode "48893"; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Office "Michigan"}
		if ($location -eq "Jackson") {Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -StreetAddress "1055 Mendell Davis Dr."; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -City "Jackson";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -State "MS";
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -PostalCode "39272";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Office "Jackson"}
		if ($location -eq "KC") {Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -StreetAddress "903 E. 104th St., Suite 130"; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -City "Kansas City";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -State "MO";
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -PostalCode "64131";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Office "Kansas City"}
		if ($location -eq "Pryor") {Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -StreetAddress "4650 54th St. MAIP bldg 601"; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -City "Pryor";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -State "OK";
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -PostalCode "74361";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Office "Pryor"}
		if ($location -eq "Warehouse") {Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -StreetAddress "123 Any street"; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -City "Jackson";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -State "MS";
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -PostalCode "39272";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Office "Warehouse"}
	
		$statusstrip1.Items.Add('Physical address changed...')
	
	}
	
	# --End User Generated Script--
	#----------------------------------------------
	#region Generated Events
	#----------------------------------------------
	
	$Form_StateCorrection_Load=
	{
		#Correct the initial state of the form to prevent the .Net maximized form issue
		$formHRUserEdit.WindowState = $InitialFormWindowState
	}
	
	$Form_Cleanup_FormClosed=
	{
		#Remove all event handlers from the controls
		try
		{
			$button3.remove_Click($button3_Click)
			$textbox5.remove_TextChanged($textbox5_TextChanged)
			$button2.remove_Click($button2_Click)
			$textbox4.remove_TextChanged($textbox4_TextChanged)
			$button1.remove_Click($button1_Click)
			$textbox3.remove_TextChanged($textbox3_TextChanged)
			$buttonSubmit.remove_Click($buttonSubmit_Click)
			$datagridview1.remove_CellContentClick($datagridview1_CellContentClick)
			$buttonSearch.remove_Click($buttonSearch_Click)
			$textbox1.remove_TextChanged($textbox1_TextChanged)
			$formHRUserEdit.remove_Load($formHRUserEdit_Load)
			$formHRUserEdit.remove_Load($Form_StateCorrection_Load)
			$formHRUserEdit.remove_FormClosed($Form_Cleanup_FormClosed)
		}
		catch [Exception]
		{ }
	}
	#endregion Generated Events

	#----------------------------------------------
	#region Generated Form Code
	#----------------------------------------------
	#
	# formHRUserEdit
	#
	$formHRUserEdit.Controls.Add($statusstrip1)
	$formHRUserEdit.Controls.Add($button3)
	$formHRUserEdit.Controls.Add($textbox5)
	$formHRUserEdit.Controls.Add($labelLocationieJacksonWar)
	$formHRUserEdit.Controls.Add($button2)
	$formHRUserEdit.Controls.Add($textbox4)
	$formHRUserEdit.Controls.Add($labelManager)
	$formHRUserEdit.Controls.Add($button1)
	$formHRUserEdit.Controls.Add($textbox3)
	$formHRUserEdit.Controls.Add($labelDepartment)
	$formHRUserEdit.Controls.Add($buttonSubmit)
	$formHRUserEdit.Controls.Add($textbox2)
	$formHRUserEdit.Controls.Add($labelJobTitle)
	$formHRUserEdit.Controls.Add($datagridview1)
	$formHRUserEdit.Controls.Add($buttonSearch)
	$formHRUserEdit.Controls.Add($textbox1)
	$formHRUserEdit.Controls.Add($labelUsername)
	$formHRUserEdit.ClientSize = '340, 373'
	$formHRUserEdit.Name = "formHRUserEdit"
	$formHRUserEdit.Text = "HR - User Edit"
	$formHRUserEdit.add_Load($formHRUserEdit_Load)
	#
	# statusstrip1
	#
	$statusstrip1.AutoSize = $False
	$statusstrip1.LayoutStyle = 'Flow'
	$statusstrip1.Location = '0, 309'
	$statusstrip1.Name = "statusstrip1"
	$statusstrip1.Size = '340, 64'
	$statusstrip1.TabIndex = 16
	#
	# button3
	#
	$button3.Location = '231, 269'
	$button3.Name = "button3"
	$button3.Size = '75, 23'
	$button3.TabIndex = 15
	$button3.Text = "Submit"
	$button3.UseVisualStyleBackColor = $True
	$button3.add_Click($button3_Click)
	#
	# textbox5
	#
	$textbox5.Location = '13, 269'
	$textbox5.Name = "textbox5"
	$textbox5.Size = '199, 20'
	$textbox5.TabIndex = 14
	$textbox5.add_TextChanged($textbox5_TextChanged)
	#
	# labelLocationieJacksonWar
	#
	$labelLocationieJacksonWar.Location = '13, 251'
	$labelLocationieJacksonWar.Name = "labelLocationieJacksonWar"
	$labelLocationieJacksonWar.Size = '277, 14'
	$labelLocationieJacksonWar.TabIndex = 13
	$labelLocationieJacksonWar.Text = "Location (i.e. Jackson, Warehouse, Michigan, KC, Pryor)"
	#
	# button2
	#
	$button2.Location = '231, 224'
	$button2.Name = "button2"
	$button2.Size = '75, 23'
	$button2.TabIndex = 12
	$button2.Text = "Submit"
	$button2.UseVisualStyleBackColor = $True
	$button2.add_Click($button2_Click)
	#
	# textbox4
	#
	$textbox4.Location = '13, 224'
	$textbox4.Name = "textbox4"
	$textbox4.Size = '199, 20'
	$textbox4.TabIndex = 11
	$textbox4.add_TextChanged($textbox4_TextChanged)
	#
	# labelManager
	#
	$labelManager.Location = '13, 204'
	$labelManager.Name = "labelManager"
	$labelManager.Size = '100, 16'
	$labelManager.TabIndex = 10
	$labelManager.Text = "Manager"
	#
	# button1
	#
	$button1.Location = '231, 177'
	$button1.Name = "button1"
	$button1.Size = '75, 23'
	$button1.TabIndex = 9
	$button1.Text = "Submit"
	$button1.UseVisualStyleBackColor = $True
	$button1.add_Click($button1_Click)
	#
	# textbox3
	#
	$textbox3.Location = '13, 177'
	$textbox3.Name = "textbox3"
	$textbox3.Size = '199, 20'
	$textbox3.TabIndex = 8
	$textbox3.add_TextChanged($textbox3_TextChanged)
	#
	# labelDepartment
	#
	$labelDepartment.Location = '13, 156'
	$labelDepartment.Name = "labelDepartment"
	$labelDepartment.Size = '100, 17'
	$labelDepartment.TabIndex = 7
	$labelDepartment.Text = "Department"
	#
	# buttonSubmit
	#
	$buttonSubmit.Location = '231, 129'
	$buttonSubmit.Name = "buttonSubmit"
	$buttonSubmit.Size = '75, 23'
	$buttonSubmit.TabIndex = 6
	$buttonSubmit.Text = "Submit"
	$buttonSubmit.UseVisualStyleBackColor = $True
	$buttonSubmit.add_Click($buttonSubmit_Click)
	#
	# textbox2
	#
	$textbox2.Location = '13, 129'
	$textbox2.Name = "textbox2"
	$textbox2.Size = '199, 20'
	$textbox2.TabIndex = 5
	#
	# labelJobTitle
	#
	$labelJobTitle.Location = '13, 108'
	$labelJobTitle.Name = "labelJobTitle"
	$labelJobTitle.Size = '100, 17'
	$labelJobTitle.TabIndex = 4
	$labelJobTitle.Text = "Job Title"
	#
	# datagridview1
	#
	$datagridview1.AllowUserToDeleteRows = $False
	$System_Windows_Forms_DataGridViewCellStyle_1 = New-Object 'System.Windows.Forms.DataGridViewCellStyle'
	$System_Windows_Forms_DataGridViewCellStyle_1.Alignment = 'MiddleLeft'
	$System_Windows_Forms_DataGridViewCellStyle_1.BackColor = 'Control'
	$System_Windows_Forms_DataGridViewCellStyle_1.Font = "Microsoft Sans Serif, 8.25pt"
	$System_Windows_Forms_DataGridViewCellStyle_1.ForeColor = 'WindowText'
	$System_Windows_Forms_DataGridViewCellStyle_1.SelectionBackColor = 'Highlight'
	$System_Windows_Forms_DataGridViewCellStyle_1.SelectionForeColor = 'HighlightText'
	$System_Windows_Forms_DataGridViewCellStyle_1.WrapMode = 'True'
	$datagridview1.ColumnHeadersDefaultCellStyle = $System_Windows_Forms_DataGridViewCellStyle_1
	$datagridview1.ColumnHeadersVisible = $False
	$System_Windows_Forms_DataGridViewCellStyle_2 = New-Object 'System.Windows.Forms.DataGridViewCellStyle'
	$System_Windows_Forms_DataGridViewCellStyle_2.Alignment = 'MiddleLeft'
	$System_Windows_Forms_DataGridViewCellStyle_2.BackColor = 'Window'
	$System_Windows_Forms_DataGridViewCellStyle_2.Font = "Microsoft Sans Serif, 8.25pt"
	$System_Windows_Forms_DataGridViewCellStyle_2.ForeColor = 'ControlText'
	$System_Windows_Forms_DataGridViewCellStyle_2.SelectionBackColor = 'Highlight'
	$System_Windows_Forms_DataGridViewCellStyle_2.SelectionForeColor = 'HighlightText'
	$System_Windows_Forms_DataGridViewCellStyle_2.WrapMode = 'False'
	$datagridview1.DefaultCellStyle = $System_Windows_Forms_DataGridViewCellStyle_2
	$datagridview1.Location = '13, 57'
	$datagridview1.Name = "datagridview1"
	$System_Windows_Forms_DataGridViewCellStyle_3 = New-Object 'System.Windows.Forms.DataGridViewCellStyle'
	$System_Windows_Forms_DataGridViewCellStyle_3.Alignment = 'MiddleLeft'
	$System_Windows_Forms_DataGridViewCellStyle_3.BackColor = 'Control'
	$System_Windows_Forms_DataGridViewCellStyle_3.Font = "Microsoft Sans Serif, 8.25pt"
	$System_Windows_Forms_DataGridViewCellStyle_3.ForeColor = 'WindowText'
	$System_Windows_Forms_DataGridViewCellStyle_3.SelectionBackColor = 'Highlight'
	$System_Windows_Forms_DataGridViewCellStyle_3.SelectionForeColor = 'HighlightText'
	$System_Windows_Forms_DataGridViewCellStyle_3.WrapMode = 'True'
	$datagridview1.RowHeadersDefaultCellStyle = $System_Windows_Forms_DataGridViewCellStyle_3
	$datagridview1.Size = '305, 48'
	$datagridview1.TabIndex = 3
	$datagridview1.TabStop = $False
	$datagridview1.add_CellContentClick($datagridview1_CellContentClick)
	#
	# buttonSearch
	#
	$buttonSearch.Location = '201, 30'
	$buttonSearch.Name = "buttonSearch"
	$buttonSearch.Size = '75, 23'
	$buttonSearch.TabIndex = 2
	$buttonSearch.Text = "Search"
	$buttonSearch.UseVisualStyleBackColor = $True
	$buttonSearch.add_Click($buttonSearch_Click)
	#
	# textbox1
	#
	$textbox1.Location = '13, 30'
	$textbox1.Name = "textbox1"
	$textbox1.Size = '181, 20'
	$textbox1.TabIndex = 1
	$textbox1.add_TextChanged($textbox1_TextChanged)
	#
	# labelUsername
	#
	$labelUsername.Location = '13, 13'
	$labelUsername.Name = "labelUsername"#------------------------------------------------------------------------
# 
#========================================================================
# Code Generated By: SAPIEN Technologies, Inc., PowerShell Studio 2012 v3.1.26
# Generated On: 3/21/2014 11:27 AM
# Generated By: bhart
#========================================================================
#----------------------------------------------
#region Application Functions
#----------------------------------------------

function OnApplicationLoad {
	#Note: This function is not called in Projects
	#Note: This function runs before the form is created
	#Note: To get the script directory in the Packager use: Split-Path $hostinvocation.MyCommand.path
	#Note: To get the console output in the Packager (Windows Mode) use: $ConsoleOutput (Type: System.Collections.ArrayList)
	#Important: Form controls cannot be accessed in this function
	#TODO: Add snapins and custom code to validate the application load
	Import-Module ActiveDirectory
	
	return $true #return true for success or false for failure
}

function OnApplicationExit {
	#Note: This function is not called in Projects
	#Note: This function runs after the form is closed
	#TODO: Add custom code to clean up and unload snapins when the application exits
	
	$script:ExitCode = 0 #Set the exit code for the Packager
}

#endregion Application Functions

#----------------------------------------------
# Generated Form Function
#----------------------------------------------
function Call-HR_User_Change_pff {

	#----------------------------------------------
	#region Import the Assemblies
	#----------------------------------------------
	[void][reflection.assembly]::Load("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
	[void][reflection.assembly]::Load("System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
	[void][reflection.assembly]::Load("System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
	[void][reflection.assembly]::Load("System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
	[void][reflection.assembly]::Load("System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
	#endregion Import Assemblies

	#----------------------------------------------
	#region Generated Form Objects
	#----------------------------------------------
	[System.Windows.Forms.Application]::EnableVisualStyles()
	$formHRUserEdit = New-Object 'System.Windows.Forms.Form'
	$statusstrip1 = New-Object 'System.Windows.Forms.StatusStrip'
	$button3 = New-Object 'System.Windows.Forms.Button'
	$textbox5 = New-Object 'System.Windows.Forms.TextBox'
	$labelLocationieJacksonWar = New-Object 'System.Windows.Forms.Label'
	$button2 = New-Object 'System.Windows.Forms.Button'
	$textbox4 = New-Object 'System.Windows.Forms.TextBox'
	$labelManager = New-Object 'System.Windows.Forms.Label'
	$button1 = New-Object 'System.Windows.Forms.Button'
	$textbox3 = New-Object 'System.Windows.Forms.TextBox'
	$labelDepartment = New-Object 'System.Windows.Forms.Label'
	$buttonSubmit = New-Object 'System.Windows.Forms.Button'
	$textbox2 = New-Object 'System.Windows.Forms.TextBox'
	$labelJobTitle = New-Object 'System.Windows.Forms.Label'
	$datagridview1 = New-Object 'System.Windows.Forms.DataGridView'
	$buttonSearch = New-Object 'System.Windows.Forms.Button'
	$textbox1 = New-Object 'System.Windows.Forms.TextBox'
	$labelUsername = New-Object 'System.Windows.Forms.Label'
	$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
	#endregion Generated Form Objects

	#----------------------------------------------
	# User Generated Script
	#----------------------------------------------
	
	
	
	
	
	
	
	$formHRUserEdit_Load={
		#TODO: Initialize Form Controls here
		#$statusbar1.Text = "Ready"
		$statusstrip1.items.add('Ready...')
	$buttonSearch.enabled = $false
	
	}
	
	$textbox1_TextChanged=
	{
	$buttonSearch.enabled = $false

	$statusstrip1.items.clear()
	$user = $(try {Get-ADUser $textbox1.Text} catch {$null})
	if ($user -ne $null) {  # valid user
		$statusstrip1.items.add("Valid User $($textbox1.Text)...")
		$buttonSearch.enabled = $true  # enable search

	} 
	else {  $statusstrip1.items.add('Username invalid...')}
				
		
	}
	
	$buttonSearch_Click={
		#TODO: Place custom script here
		
		$users = New-Object System.Collections.ArrayList
				$userInfoDetail = Get-aduser  $textbox1.Text -ErrorAction Stop -property SAMAccountName,Name,title,description,department,manager,city
				$userinfo = $userInfoDetail | select SAMAccountName,Name
						
		if($userinfo.count) {			$users.addrange($userinfo)			}
						else { 			$users.Add($userinfo)				}
						
						$textbox2.Text = $userinfodetail.title
						$textbox3.text =  $userinfodetail.department
						if ($userInfoDetail.manager -ne $null -and $userInfoDetail.manager -ne "") {$textbox4.text =  $userInfoDetail.manager.split(",")[0].split("=")[1]}
						$textbox4.text = $null
						$textbox5.text =   $userinfodetail.City
						$datagridview1.DataSource = $users
						$formHRUserEdit.refresh()
	
	}
	
	
	function Load-DataGridView
	{
		<#
		.SYNOPSIS
			This functions helps you load items into a DataGridView.
	
		.DESCRIPTION
			Use this function to dynamically load items into the DataGridView control.
	
		.PARAMETER  DataGridView
			The ComboBox control you want to add items to.
	
		.PARAMETER  Item
			The object or objects you wish to load into the ComboBox's items collection.
		
		.PARAMETER  DataMember
			Sets the name of the list or table in the data source for which the DataGridView is displaying data.
	
		#>
		Param (
			[ValidateNotNull()]
			[Parameter(Mandatory=$true)]
			[System.Windows.Forms.DataGridView]$DataGridView,
			[ValidateNotNull()]
			[Parameter(Mandatory=$true)]
			$Item,
		    [Parameter(Mandatory=$false)]
			[string]$DataMember
		)
		$DataGridView.SuspendLayout()
		$DataGridView.DataMember = $DataMember
		
		if ($Item -is [System.ComponentModel.IListSource]`
		-or $Item -is [System.ComponentModel.IBindingList] -or $Item -is [System.ComponentModel.IBindingListView] )
		{
			$DataGridView.DataSource = $Item
		}
		else
		{
			$array = New-Object System.Collections.ArrayList
			
			if ($Item -is [System.Collections.IList])
			{
				$array.AddRange($Item)
			}
			else
			{	
				$array.Add($Item)	
			}
			$DataGridView.DataSource = $array
		}
		
		$DataGridView.ResumeLayout()
	}
	#endregion
	
	$datagridview1_CellContentClick=[System.Windows.Forms.DataGridViewCellEventHandler]{
	#Event Argument: $_ = [System.Windows.Forms.DataGridViewCellEventArgs]
		#TODO: Place custom script here
		
	}
	
	$buttonSubmit_Click={
		#TODO: Place custom script here
		Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Description $textbox2.Text 
		Set-ADUser -identity $datagridview1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Title $textbox2.Text
		$statusstrip1.Items.Add('Job title changed...')
	}
	
	$textbox3_TextChanged={
		#TODO: Place custom script here
		
	}
	
	$button1_Click={
		#TODO: Place custom script here
		Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Department $textbox3.text
		$statusstrip1.Items.Add('Department changed...')
	}
	
	$textbox4_TextChanged={
		#TODO: Place custom script here
		
	}
	
	$button2_Click={
		#TODO: Place custom script here
		Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Manager $textbox4.Text
		$statusstrip1.Items.Add('Manager changed...')
	}
	
	$textbox5_TextChanged={
		#TODO: Place custom script here
		
	}
	
	$button3_Click={
		#TODO: Place custom script here
		#Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop - $textbox5.Text
		$location = $textbox5.Text
		if ($location -eq "Michigan") {Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -streetaddress "525 S. Coldwater Rd."; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -City "Weidman";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -State "MI";
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -PostalCode "48893"; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Office "Michigan"}
		if ($location -eq "Jackson") {Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -StreetAddress "1055 Mendell Davis Dr."; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -City "Jackson";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -State "MS";
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -PostalCode "39272";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Office "Jackson"}
		if ($location -eq "KC") {Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -StreetAddress "903 E. 104th St., Suite 130"; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -City "Kansas City";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -State "MO";
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -PostalCode "64131";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Office "Kansas City"}
		if ($location -eq "Pryor") {Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -StreetAddress "4650 54th St. MAIP bldg 601"; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -City "Pryor";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -State "OK";
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -PostalCode "74361";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Office "Pryor"}
		if ($location -eq "Warehouse") {Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -StreetAddress "123 Any street"; 
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -City "Jackson";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -State "MS";
			Set-ADUser -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -PostalCode "39272";
			Set-ADUser  -Identity $dataGridView1.SelectedCells[0].Value.ToString() -ErrorAction Stop -Office "Warehouse"}
	
		$statusstrip1.Items.Add('Physical address changed...')
	
	}
	
	# --End User Generated Script--
	#----------------------------------------------
	#region Generated Events
	#----------------------------------------------
	
	$Form_StateCorrection_Load=
	{
		#Correct the initial state of the form to prevent the .Net maximized form issue
		$formHRUserEdit.WindowState = $InitialFormWindowState
	}
	
	$Form_Cleanup_FormClosed=
	{
		#Remove all event handlers from the controls
		try
		{
			$button3.remove_Click($button3_Click)
			$textbox5.remove_TextChanged($textbox5_TextChanged)
			$button2.remove_Click($button2_Click)
			$textbox4.remove_TextChanged($textbox4_TextChanged)
			$button1.remove_Click($button1_Click)
			$textbox3.remove_TextChanged($textbox3_TextChanged)
			$buttonSubmit.remove_Click($buttonSubmit_Click)
			$datagridview1.remove_CellContentClick($datagridview1_CellContentClick)
			$buttonSearch.remove_Click($buttonSearch_Click)
			$textbox1.remove_TextChanged($textbox1_TextChanged)
			$formHRUserEdit.remove_Load($formHRUserEdit_Load)
			$formHRUserEdit.remove_Load($Form_StateCorrection_Load)
			$formHRUserEdit.remove_FormClosed($Form_Cleanup_FormClosed)
		}
		catch [Exception]
		{ }
	}
	#endregion Generated Events

	#----------------------------------------------
	#region Generated Form Code
	#----------------------------------------------
	#
	# formHRUserEdit
	#
	$formHRUserEdit.Controls.Add($statusstrip1)
	$formHRUserEdit.Controls.Add($button3)
	$formHRUserEdit.Controls.Add($textbox5)
	$formHRUserEdit.Controls.Add($labelLocationieJacksonWar)
	$formHRUserEdit.Controls.Add($button2)
	$formHRUserEdit.Controls.Add($textbox4)
	$formHRUserEdit.Controls.Add($labelManager)
	$formHRUserEdit.Controls.Add($button1)
	$formHRUserEdit.Controls.Add($textbox3)
	$formHRUserEdit.Controls.Add($labelDepartment)
	$formHRUserEdit.Controls.Add($buttonSubmit)
	$formHRUserEdit.Controls.Add($textbox2)
	$formHRUserEdit.Controls.Add($labelJobTitle)
	$formHRUserEdit.Controls.Add($datagridview1)
	$formHRUserEdit.Controls.Add($buttonSearch)
	$formHRUserEdit.Controls.Add($textbox1)
	$formHRUserEdit.Controls.Add($labelUsername)
	$formHRUserEdit.ClientSize = '340, 373'
	$formHRUserEdit.Name = "formHRUserEdit"
	$formHRUserEdit.Text = "HR - User Edit"
	$formHRUserEdit.add_Load($formHRUserEdit_Load)
	#
	# statusstrip1
	#
	$statusstrip1.AutoSize = $False
	$statusstrip1.LayoutStyle = 'Flow'
	$statusstrip1.Location = '0, 309'
	$statusstrip1.Name = "statusstrip1"
	$statusstrip1.Size = '340, 64'
	$statusstrip1.TabIndex = 16
	#
	# button3
	#
	$button3.Location = '231, 269'
	$button3.Name = "button3"
	$button3.Size = '75, 23'
	$button3.TabIndex = 15
	$button3.Text = "Submit"
	$button3.UseVisualStyleBackColor = $True
	$button3.add_Click($button3_Click)
	#
	# textbox5
	#
	$textbox5.Location = '13, 269'
	$textbox5.Name = "textbox5"
	$textbox5.Size = '199, 20'
	$textbox5.TabIndex = 14
	$textbox5.add_TextChanged($textbox5_TextChanged)
	#
	# labelLocationieJacksonWar
	#
	$labelLocationieJacksonWar.Location = '13, 251'
	$labelLocationieJacksonWar.Name = "labelLocationieJacksonWar"
	$labelLocationieJacksonWar.Size = '277, 14'
	$labelLocationieJacksonWar.TabIndex = 13
	$labelLocationieJacksonWar.Text = "Location (i.e. Jackson, Warehouse, Michigan, KC, Pryor)"
	#
	# button2
	#
	$button2.Location = '231, 224'
	$button2.Name = "button2"
	$button2.Size = '75, 23'
	$button2.TabIndex = 12
	$button2.Text = "Submit"
	$button2.UseVisualStyleBackColor = $True
	$button2.add_Click($button2_Click)
	#
	# textbox4
	#
	$textbox4.Location = '13, 224'
	$textbox4.Name = "textbox4"
	$textbox4.Size = '199, 20'
	$textbox4.TabIndex = 11
	$textbox4.add_TextChanged($textbox4_TextChanged)
	#
	# labelManager
	#
	$labelManager.Location = '13, 204'
	$labelManager.Name = "labelManager"
	$labelManager.Size = '100, 16'
	$labelManager.TabIndex = 10
	$labelManager.Text = "Manager"
	#
	# button1
	#
	$button1.Location = '231, 177'
	$button1.Name = "button1"
	$button1.Size = '75, 23'
	$button1.TabIndex = 9
	$button1.Text = "Submit"
	$button1.UseVisualStyleBackColor = $True
	$button1.add_Click($button1_Click)
	#
	# textbox3
	#
	$textbox3.Location = '13, 177'
	$textbox3.Name = "textbox3"
	$textbox3.Size = '199, 20'
	$textbox3.TabIndex = 8
	$textbox3.add_TextChanged($textbox3_TextChanged)
	#
	# labelDepartment
	#
	$labelDepartment.Location = '13, 156'
	$labelDepartment.Name = "labelDepartment"
	$labelDepartment.Size = '100, 17'
	$labelDepartment.TabIndex = 7
	$labelDepartment.Text = "Department"
	#
	# buttonSubmit
	#
	$buttonSubmit.Location = '231, 129'
	$buttonSubmit.Name = "buttonSubmit"
	$buttonSubmit.Size = '75, 23'
	$buttonSubmit.TabIndex = 6
	$buttonSubmit.Text = "Submit"
	$buttonSubmit.UseVisualStyleBackColor = $True
	$buttonSubmit.add_Click($buttonSubmit_Click)
	#
	# textbox2
	#
	$textbox2.Location = '13, 129'
	$textbox2.Name = "textbox2"
	$textbox2.Size = '199, 20'
	$textbox2.TabIndex = 5
	#
	# labelJobTitle
	#
	$labelJobTitle.Location = '13, 108'
	$labelJobTitle.Name = "labelJobTitle"
	$labelJobTitle.Size = '100, 17'
	$labelJobTitle.TabIndex = 4
	$labelJobTitle.Text = "Job Title"
	#
	# datagridview1
	#
	$datagridview1.AllowUserToDeleteRows = $False
	$System_Windows_Forms_DataGridViewCellStyle_1 = New-Object 'System.Windows.Forms.DataGridViewCellStyle'
	$System_Windows_Forms_DataGridViewCellStyle_1.Alignment = 'MiddleLeft'
	$System_Windows_Forms_DataGridViewCellStyle_1.BackColor = 'Control'
	$System_Windows_Forms_DataGridViewCellStyle_1.Font = "Microsoft Sans Serif, 8.25pt"
	$System_Windows_Forms_DataGridViewCellStyle_1.ForeColor = 'WindowText'
	$System_Windows_Forms_DataGridViewCellStyle_1.SelectionBackColor = 'Highlight'
	$System_Windows_Forms_DataGridViewCellStyle_1.SelectionForeColor = 'HighlightText'
	$System_Windows_Forms_DataGridViewCellStyle_1.WrapMode = 'True'
	$datagridview1.ColumnHeadersDefaultCellStyle = $System_Windows_Forms_DataGridViewCellStyle_1
	$datagridview1.ColumnHeadersVisible = $False
	$System_Windows_Forms_DataGridViewCellStyle_2 = New-Object 'System.Windows.Forms.DataGridViewCellStyle'
	$System_Windows_Forms_DataGridViewCellStyle_2.Alignment = 'MiddleLeft'
	$System_Windows_Forms_DataGridViewCellStyle_2.BackColor = 'Window'
	$System_Windows_Forms_DataGridViewCellStyle_2.Font = "Microsoft Sans Serif, 8.25pt"
	$System_Windows_Forms_DataGridViewCellStyle_2.ForeColor = 'ControlText'
	$System_Windows_Forms_DataGridViewCellStyle_2.SelectionBackColor = 'Highlight'
	$System_Windows_Forms_DataGridViewCellStyle_2.SelectionForeColor = 'HighlightText'
	$System_Windows_Forms_DataGridViewCellStyle_2.WrapMode = 'False'
	$datagridview1.DefaultCellStyle = $System_Windows_Forms_DataGridViewCellStyle_2
	$datagridview1.Location = '13, 57'
	$datagridview1.Name = "datagridview1"
	$System_Windows_Forms_DataGridViewCellStyle_3 = New-Object 'System.Windows.Forms.DataGridViewCellStyle'
	$System_Windows_Forms_DataGridViewCellStyle_3.Alignment = 'MiddleLeft'
	$System_Windows_Forms_DataGridViewCellStyle_3.BackColor = 'Control'
	$System_Windows_Forms_DataGridViewCellStyle_3.Font = "Microsoft Sans Serif, 8.25pt"
	$System_Windows_Forms_DataGridViewCellStyle_3.ForeColor = 'WindowText'
	$System_Windows_Forms_DataGridViewCellStyle_3.SelectionBackColor = 'Highlight'
	$System_Windows_Forms_DataGridViewCellStyle_3.SelectionForeColor = 'HighlightText'
	$System_Windows_Forms_DataGridViewCellStyle_3.WrapMode = 'True'
	$datagridview1.RowHeadersDefaultCellStyle = $System_Windows_Forms_DataGridViewCellStyle_3
	$datagridview1.Size = '305, 48'
	$datagridview1.TabIndex = 3
	$datagridview1.TabStop = $False
	$datagridview1.add_CellContentClick($datagridview1_CellContentClick)
	#
	# buttonSearch
	#
	$buttonSearch.Location = '201, 30'
	$buttonSearch.Name = "buttonSearch"
	$buttonSearch.Size = '75, 23'
	$buttonSearch.TabIndex = 2
	$buttonSearch.Text = "Search"
	$buttonSearch.UseVisualStyleBackColor = $True
	$buttonSearch.add_Click($buttonSearch_Click)
	#
	# textbox1
	#
	$textbox1.Location = '13, 30'
	$textbox1.Name = "textbox1"
	$textbox1.Size = '181, 20'
	$textbox1.TabIndex = 1
	$textbox1.add_TextChanged($textbox1_TextChanged)
	#
	# labelUsername
	#
	$labelUsername.Location = '13, 13'
	$labelUsername.Name = "labelUsername"
	$labelUsername.Size = '100, 13'
	$labelUsername.TabIndex = 0
	$labelUsername.Text = "Username"
	#endregion Generated Form Code

	#----------------------------------------------

	#Save the initial state of the form
	$InitialFormWindowState = $formHRUserEdit.WindowState
	#Init the OnLoad event to correct the initial state of the form
	$formHRUserEdit.add_Load($Form_StateCorrection_Load)
	#Clean up the control events
	$formHRUserEdit.add_FormClosed($Form_Cleanup_FormClosed)
	#Show the Form
	return $formHRUserEdit.ShowDialog()

} #End Function

#Call OnApplicationLoad to initialize
if((OnApplicationLoad) -eq $true)
{
	#Call the form
	Call-HR_User_Change_pff | Out-Null
	#Perform cleanup
	OnApplicationExit
}
	$labelUsername.Size = '100, 13'
	$labelUsername.TabIndex = 0
	$labelUsername.Text = "Username"
	#endregion Generated Form Code

	#----------------------------------------------

	#Save the initial state of the form
	$InitialFormWindowState = $formHRUserEdit.WindowState
	#Init the OnLoad event to correct the initial state of the form
	$formHRUserEdit.add_Load($Form_StateCorrection_Load)
	#Clean up the control events
	$formHRUserEdit.add_FormClosed($Form_Cleanup_FormClosed)
	#Show the Form
	return $formHRUserEdit.ShowDialog()

} #End Function

#Call OnApplicationLoad to initialize
if((OnApplicationLoad) -eq $true)
{
	#Call the form
	Call-HR_User_Change_pff | Out-Null
	#Perform cleanup
	OnApplicationExit
}

Open in new window

0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question