Jump to content

Bensp1234

Members
  • Posts

    2
  • Joined

  • Last visited

Reputation

0 Neutral

About Bensp1234

  1. Hello protocol, thanks for the reply, We tired that here before unfortunately we found that teacher able to access the AD was a bad idea as they where accidentally deleting students and changing details other than passwords that did not need to be changed.
  2. Hello everyone, I am trying to make a program inside of power shell/powershell studio that lets teachers be able to change students passwords pulling the information from AD. So far I have managed to make AD pull information into my GUI and display the information however I am struggling to get a working search box inside of power shell studio to work pulling information from AD. As well as this I am struggling to get the program to only search from inside one OU rather than how it is at the moment where it is pulling from the entire root directory. The source document for powershell studio is here: password reset.zip Other wise the code is as follows: Mainform.psf $MainForm_Load={ #TODO: Initialize Form Controls here } $buttonCallChildForm_Click={ #TODO: Place custom script here if((Call-ChildForm_psf) -eq 'OK') { } } $A_Click={ #TODO: Place custom script here $buttona.text = "A" $users = Get-ADUser -f { surname -like 'A*' } Load-ListBox -Listbox $listbox1 -DisplayMember name -Items $users #TODO: Place custom script here } #region Control Helper Functions function Load-ListBox { <# .SYNOPSIS This functions helps you load items into a ListBox or CheckedListBox. .DESCRIPTION Use this function to dynamically load items into the ListBox control. .PARAMETER ListBox The ListBox control you want to add items to. .PARAMETER Items The object or objects you wish to load into the ListBox's Items collection. .PARAMETER DisplayMember Indicates the property to display for the items in this control. .PARAMETER Append Adds the item(s) to the ListBox without clearing the Items collection. .EXAMPLE Load-ListBox $ListBox1 "Red", "White", "Blue" .EXAMPLE Load-ListBox $listBox1 "Red" -Append Load-ListBox $listBox1 "White" -Append Load-ListBox $listBox1 "Blue" -Append .EXAMPLE Load-ListBox $listBox1 (Get-Process) "ProcessName" #> Param ( [ValidateNotNull()] [Parameter(Mandatory=$true)] [system.Windows.Forms.ListBox]$ListBox, [ValidateNotNull()] [Parameter(Mandatory=$true)] $Items, [Parameter(Mandatory=$false)] [string]$DisplayMember, [switch]$Append ) if(-not $Append) { $listBox.Items.Clear() } if($Items -is [system.Windows.Forms.ListBox+ObjectCollection] -or $Items -is [system.Collections.ICollection]) { $listBox.Items.AddRange($Items) } elseif ($Items -is [system.Collections.IEnumerable]) { $listBox.BeginUpdate() foreach($obj in $Items) { $listBox.Items.Add($obj) } $listBox.EndUpdate() } else { $listBox.Items.Add($Items) } $listBox.DisplayMember = $DisplayMember } #endregion $buttonB_Click={ #TODO: Place custom script here $buttonB.text = "B" $users = Get-ADUser -SearchBase "ou=Student" -f { surname -like 'B*' } Load-ListBox -Listbox $listbox1 -DisplayMember Name -Items $users } globals.sp1 #-------------------------------------------- # Declare Global Variables and Functions here #-------------------------------------------- #Sample function that provides the location of the script function Get-ScriptDirectory { <# .SYNOPSIS Get-ScriptDirectory returns the proper location of the script. .OUTPUTS System.String .NOTES Returns the correct path within a packaged executable. #> [OutputType([string])] param () if ($hostinvocation -ne $null) { Split-Path $hostinvocation.MyCommand.path } else { Split-Path $script:MyInvocation.MyCommand.Path } } #Sample variable that provides the location of the script [string]$ScriptDirectory = Get-ScriptDirectory
×
×
  • Create New...