Windows Platform

Powershell Script to Manage your tasks

If you want to plan and manage all of your team’s tasks and projects in one place then, task manager Powershell script is the best solution for you. Powershell Task management will help to track tasks from beginning to end, you can delegate subtasks to teammates, and set the deadlines to make sure projects get done on time.

 

[reflection.assembly]::loadwithpartialname(“System.Windows.Forms”) | Out-Null
[reflection.assembly]::loadwithpartialname(“System.Drawing”) | Out-Null

function AddData{
param($procs, $list)

$list.BeginUpdate()
$list.items.Clear()
foreach ($proc in $procs)
{

$item = New-Object System.Windows.Forms.ListViewItem($proc.task)

[Void]$item.SubItems.Add($proc.date_creation)

if ($proc.date_complete -ne $null)
{
[Void]$item.SubItems.Add($proc.date_complete)
}
else
{
[Void]$item.SubItems.Add(“”)
}

[Void]$item.SubItems.Add($proc.status)
[Void]$item.SubItems.Add($proc.alert)
[Void]$item.SubItems.Add($proc.note)
[Void]$item.SubItems.Add($proc.askby)
[Void]$item.SubItems.Add($proc.priority)
[Void]$item.SubItems.Add($proc.pourcentage)

[Void] $list.Items.Add($item)
}
$list.EndUpdate()
}

function UpdateAddData{

}
function SortList{
param ([int32]$column)

foreach($c in $this.Columns)
{
if ($column -eq $c.index )
{
if($c.tag.sortOrder -eq ‘Ascending’)
{
$c.tag.sortOrder =’Descending’
$sorted = $procs | Sort $c.text -Descending
}
else
{
$c.tag.sortOrder =’Ascending’
$sorted = $procs | Sort $c.text
}
AddData $sorted $this
}
}
}
Function datepicker {
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing

$formdate = New-Object Windows.Forms.Form

$formdate.Text = ‘Select a Date’
$formdate.Size = New-Object Drawing.Size @(243,230)
$formdate.StartPosition = ‘CenterScreen’

$calendarTask = New-Object System.Windows.Forms.MonthCalendar
$calendarTask.ShowTodayCircle = $false
$calendarTask.MaxSelectionCount = 1
$formdate.Controls.Add($calendarTask)

$OKButtoncal = New-Object System.Windows.Forms.Button
$OKButtoncal.Location = New-Object System.Drawing.Point(38,165)
$OKButtoncal.Size = New-Object System.Drawing.Size(75,23)
$OKButtoncal.Text = ‘OK’
$OKButtoncal.DialogResult = [System.Windows.Forms.DialogResult]::OK
$formdate.AcceptButton = $OKButtoncal
$formdate.Controls.Add($OKButtoncal)

$CancelButtoncal = New-Object System.Windows.Forms.Button
$CancelButtoncal.Location = New-Object System.Drawing.Point(113,165)
$CancelButtoncal.Size = New-Object System.Drawing.Size(75,23)
$CancelButtoncal.Text = ‘Cancel’
$CancelButtoncal.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$formdate.CancelButton = $CancelButtoncal
$formdate.Controls.Add($CancelButtoncal)

$formdate.Topmost = $true

$result = $formdate.ShowDialog()

if ($result -eq [System.Windows.Forms.DialogResult]::OK)
{
$Global:date = $calendarTask.SelectionStart
$complet_date_text_field.Text = $date
}
}
Function savetask {

$newtask = $task_text_field.Text

if ($newtask) {
$a=Import-Csv C:\temp\UsersList.csv
$newposition = $a.count + 1
$newdate = Get-Date
$newstatus = $Status_ListBox.SelectedItem.ToString()
$newnote = $add_note_text_field.Text
$newaskby = $askby_ListBox.SelectedItem.ToString()
$newpriority = $priority_ListBox.SelectedItem.ToString()
$newpourcent = $total_complete_ListBox.SelectedItem.ToString()
[IO.File]::AppendAllText(“c:\temp\UsersList.csv”,”abc”,[System.Text.Encoding]::UTF8)
Add-Content c:\temp\UsersList.csv $newposition”,”$newtask”,”$newdate”,,”$newstatus”,NO,”$newnote”,”$newaskby”,”$newpriority”,”$newpourcent
$formtask.Close()
refreshmoi
}
else {
[System.Windows.Forms.MessageBox]::Show(“Task Field can’t be empty”,”Message”,1)
}
}
Function newtask {
# Debut de l’interface graphique – Grosseur et nom de la fenêtre
$Formtask = New-Object System.Windows.Forms.Form
$formtask.Text = “Edit Task”
$formtask.Size = New-Object System.Drawing.Size(300,150)
$formtask.StartPosition = “CenterScreen”
$formtask.Width = 690
$formtask.Height = 400

$Font = New-Object System.Drawing.Font(“Times New Roman”,12)
$formtask.Font = $Font
$task_label = New-Object System.Windows.Forms.Label
$task_label.Location = New-Object System.Drawing.Size(10,10)
$task_label.Size = New-Object System.Drawing.Size(240,30)
$task_label.Text = “Task :”
$formtask.Controls.Add($task_label)

$task_text_field = New-Object System.Windows.Forms.textBox
$task_text_field.Location = New-Object System.Drawing.Size(10,40)
$task_text_field.Size = New-Object System.Drawing.Size(510,80)
$task_text_field.Multiline = $true
$task_text_field.ScrollBars = “Vertical”
$formtask.Controls.Add($task_text_field)

$add_note_label = New-Object System.Windows.Forms.Label
$add_note_label.Location = New-Object System.Drawing.Size(10,130)
$add_note_label.Size = New-Object System.Drawing.Size(240,30)
$add_note_label.Text = “Add note :”
$formtask.Controls.Add($add_note_label)

$add_note_text_field = New-Object System.Windows.Forms.textBox
$add_note_text_field.Location = New-Object System.Drawing.Size(10,160)
$add_note_text_field.Size = New-Object System.Drawing.Size(510,150)
$add_note_text_field.Multiline = $true
$add_note_text_field.ScrollBars = “Vertical”
$formtask.Controls.Add($add_note_text_field)

$complet_date_label = New-Object System.Windows.Forms.Label
$complet_date_label.Location = New-Object System.Drawing.Size(540,10)
$complet_date_label.Size = New-Object System.Drawing.Size(240,30)
$complet_date_label.Text = “Complete Date :”
$formtask.Controls.Add($complet_date_label)

$complet_date_text_field = New-Object System.Windows.Forms.button
$complet_date_text_field.Location = New-Object System.Drawing.Size(540,40)
$complet_date_text_field.Size = New-Object System.Drawing.Size(120,30)
$complet_date_text_field.Text = “”
$complet_date_text_field.Add_Click({datepicker})
$formtask.Controls.Add($complet_date_text_field)

$Status_label = New-Object System.Windows.Forms.Label
$Status_label.Location = New-Object System.Drawing.Size(540,80)
$Status_label.Size = New-Object System.Drawing.Size(240,30)
$Status_label.Text = “Status :”
$formtask.Controls.Add($Status_label)

$askby_label = New-Object System.Windows.Forms.Label
$askby_label.Location = New-Object System.Drawing.Size(540,150)
$askby_label.Size = New-Object System.Drawing.Size(240,30)
$askby_label.Text = “Ask by :”
$formtask.Controls.Add($askby_label)

$priority_label = New-Object System.Windows.Forms.Label
$priority_label.Location = New-Object System.Drawing.Size(540,290)
$priority_label.Size = New-Object System.Drawing.Size(240,30)
$priority_label.Text = “Priority :”
$formtask.Controls.Add($priority_label)

$priority_ListBox = New-Object System.Windows.Forms.ComboBox
$priority_ListBox.Location = New-Object System.Drawing.Size(540,320)
$priority_ListBox.Size = New-Object System.Drawing.Size(120,80)
$priority_ListBox.Height = 80

[void] $priority_ListBox.Items.Add(“Low”)
[void] $priority_ListBox.Items.Add(“Normal”)
[void] $priority_ListBox.Items.Add(“High”)
[void] $priority_ListBox.Items.Add(“Urgent”)
$priority_ListBox.Text = “Normal”;
$priority_ListBox.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
$formtask.Controls.Add($priority_ListBox)

$completenumber_label = New-Object System.Windows.Forms.Label
$completenumber_label.Location = New-Object System.Drawing.Size(540,220)
$completenumber_label.Size = New-Object System.Drawing.Size(240,30)
$completenumber_label.Text = “% Completed :”
$formtask.Controls.Add($completenumber_label)

$Status_ListBox = New-Object System.Windows.Forms.ComboBox
$Status_ListBox.Location = New-Object System.Drawing.Size(540,110)
$Status_ListBox.Size = New-Object System.Drawing.Size(120,80)
$Status_ListBox.Height = 80

[void] $Status_ListBox.Items.Add(“Started”)
[void] $Status_ListBox.Items.Add(“Prioritized”)
[void] $Status_ListBox.Items.Add(“Holding”)
[void] $Status_ListBox.Items.Add(“Finished”)
$Status_ListBox.Text = “Started”;
$Status_ListBox.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
$formtask.Controls.Add($Status_ListBox)

$total_complete_ListBox = New-Object System.Windows.Forms.ComboBox
$total_complete_ListBox.Location = New-Object System.Drawing.Size(540,250)
$total_complete_ListBox.Size = New-Object System.Drawing.Size(120,80)
$total_complete_ListBox.Height = 80

[void] $total_complete_ListBox.Items.Add(“0”)
[void] $total_complete_ListBox.Items.Add(“10”)
[void] $total_complete_ListBox.Items.Add(“20”)
[void] $total_complete_ListBox.Items.Add(“30”)
[void] $total_complete_ListBox.Items.Add(“40”)
[void] $total_complete_ListBox.Items.Add(“50”)
[void] $total_complete_ListBox.Items.Add(“60”)
[void] $total_complete_ListBox.Items.Add(“70”)
[void] $total_complete_ListBox.Items.Add(“80”)
[void] $total_complete_ListBox.Items.Add(“90”)
[void] $total_complete_ListBox.Items.Add(“100”)

$total_complete_ListBox.Text = “0”;
$total_complete_ListBox.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
$formtask.Controls.Add($total_complete_ListBox)

$Status_value = $Status_ListBox.SelectedItem.ToString();

$askby_ListBox = New-Object System.Windows.Forms.ComboBox
$askby_ListBox.Location = New-Object System.Drawing.Size(540,180)
$askby_ListBox.Size = New-Object System.Drawing.Size(120,80)
$askby_ListBox.Height = 80

[void] $askby_ListBox.Items.Add(“Admin”)
[void] $askby_ListBox.Items.Add(“Client”)
[void] $askby_ListBox.Items.Add(“Tech”)

$askby_ListBox.Text = “Audain”;

$askby_ListBox.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
$formtask.Controls.Add($askby_ListBox)

$x = $Status_ListBox.SelectedItem.ToString();

#Afficher bouton search
$saveButton = New-Object System.Windows.Forms.Button
$saveButton.Location = New-Object System.Drawing.Size(10,330)
$saveButton.Size = New-Object System.Drawing.Size(100,23)
$saveButton.Text = “Save”
$saveButton.Add_Click({savetask})

$formtask.Controls.Add($saveButton)

#Afficher bouton quitter
$quitButton = New-Object System.Windows.Forms.Button
$quitButton.Location = New-Object System.Drawing.Size(130,330)
$quitButton.Size = New-Object System.Drawing.Size(100,23)
$quitButton.Text = “Close”
$QuitButton.Add_Click(({$formtask.Close()}))
$formtask.Controls.Add($quitButton)

#Démarer le formulaire
#Show form
$formtask.Topmost = $True

[void] $formtask.ShowDialog()
}
Function itemselect{
$editvalue = 0

foreach($item in $List.SelectedItems){

foreach($i in $item.SubItems){
$editvalue = $editvalue + 1
switch ($editvalue) {
1 {
$edittask = $i.Text
}
2 {
$editcreation = $i.Text

}
3 {
$editcomplete = $i.Text

}
4 {
$editstatus = $i.Text

}
5 {
$editalert = $i.Text

}
6 {
$editnote = $i.Text

}
7 {
$editaskby = $i.Text

}
8 {
$editpriority = $i.Text

}
9 {
$editporcentage = $i.Text

}
}
}
}

# Task window
$formtaskedit = New-Object System.Windows.Forms.Form
$formtaskedit.Text = “Edit Task”
$formtaskedit.Size = New-Object System.Drawing.Size(300,150)
$formtaskedit.StartPosition = “CenterScreen”
$formtaskedit.Width = 690
$formtaskedit.Height = 560

$Font = New-Object System.Drawing.Font(“Times New Roman”,12)
$formtaskedit.Font = $Font
$task_label = New-Object System.Windows.Forms.Label
$task_label.Location = New-Object System.Drawing.Size(10,10)
$task_label.Size = New-Object System.Drawing.Size(240,30)
$task_label.Text = “Task :”
$formtaskedit.Controls.Add($task_label)

$task_text_field = New-Object System.Windows.Forms.textBox
$task_text_field.Location = New-Object System.Drawing.Size(10,40)
$task_text_field.Size = New-Object System.Drawing.Size(510,180)
$task_text_field.Multiline = $true
$task_text_field.text = $edittask
$task_text_field.ScrollBars = “Vertical”

$formtaskedit.Controls.Add($task_text_field)

$add_note_label = New-Object System.Windows.Forms.Label
$add_note_label.Location = New-Object System.Drawing.Size(10,230)
$add_note_label.Size = New-Object System.Drawing.Size(240,30)
$add_note_label.Text = “Note :”
$formtaskedit.Controls.Add($add_note_label)

$add_note_text_field = New-Object System.Windows.Forms.textBox
$add_note_text_field.Location = New-Object System.Drawing.Size(10,260)
$add_note_text_field.Size = New-Object System.Drawing.Size(510,180)
$add_note_text_field.Multiline = $true
$add_note_text_field.ScrollBars = “Vertical”
$add_note_text_field.text = $editnote
$formtaskedit.Controls.Add($add_note_text_field)

$note_label = New-Object System.Windows.Forms.Label
$note_label.Location = New-Object System.Drawing.Size(540,430)
$note_label.Size = New-Object System.Drawing.Size(100,30)
$note_label.Text = “Priority :”
$formtaskedit.Controls.Add($note_label)

$priority_ListBox = New-Object System.Windows.Forms.ComboBox
$priority_ListBox.Location = New-Object System.Drawing.Size(540,460)
$priority_ListBox.Size = New-Object System.Drawing.Size(120,80)
$priority_ListBox.Height = 80

[void] $priority_ListBox.Items.Add(“Low”)
[void] $priority_ListBox.Items.Add(“Normal”)
[void] $priority_ListBox.Items.Add(“High”)
[void] $priority_ListBox.Items.Add(“Urgent”)
$priority_ListBox.Text = $editpriority;
$priority_ListBox.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
$formtaskedit.Controls.Add($priority_ListBox)

$creation_date_label = New-Object System.Windows.Forms.Label
$creation_date_label.Location = New-Object System.Drawing.Size(540,10)
$creation_date_label.Size = New-Object System.Drawing.Size(240,30)
$creation_date_label.Text = “Creation Date :”
$formtaskedit.Controls.Add($creation_date_label)

$creation_date_text_field = New-Object System.Windows.Forms.textBox
$creation_date_text_field.Location = New-Object System.Drawing.Size(540,40)
$creation_date_text_field.Size = New-Object System.Drawing.Size(120,30)
$creation_date_text_field.ReadOnly = $true
$creation_date_text_field.text = $editcreation
$formtaskedit.Controls.Add($creation_date_text_field)

$complet_date_label = New-Object System.Windows.Forms.Label
$complet_date_label.Location = New-Object System.Drawing.Size(540,80)
$complet_date_label.Size = New-Object System.Drawing.Size(240,30)
$complet_date_label.Text = “Due Date :”
$formtaskedit.Controls.Add($complet_date_label)

$Status_label = New-Object System.Windows.Forms.Label
$Status_label.Location = New-Object System.Drawing.Size(540,150)
$Status_label.Size = New-Object System.Drawing.Size(240,30)
$Status_label.Text = “Status :”
$formtaskedit.Controls.Add($Status_label)

$alert_label = New-Object System.Windows.Forms.Label
$alert_label.Location = New-Object System.Drawing.Size(540,220)
$alert_label.Size = New-Object System.Drawing.Size(240,30)
$alert_label.Text = “Alert :”
$formtaskedit.Controls.Add($alert_label)

$askby_label = New-Object System.Windows.Forms.Label
$askby_label.Location = New-Object System.Drawing.Size(540,290)
$askby_label.Size = New-Object System.Drawing.Size(240,30)
$askby_label.Text = “Ask by :”
$formtaskedit.Controls.Add($askby_label)

$completenumber_label = New-Object System.Windows.Forms.Label
$completenumber_label.Location = New-Object System.Drawing.Size(540,360)
$completenumber_label.Size = New-Object System.Drawing.Size(240,30)
$completenumber_label.Text = “% Completed :”
$formtaskedit.Controls.Add($completenumber_label)

$Status_ListBox = New-Object System.Windows.Forms.ComboBox
$Status_ListBox.Location = New-Object System.Drawing.Size(540,180)
$Status_ListBox.Size = New-Object System.Drawing.Size(120,80)
$Status_ListBox.Height = 80

[void] $Status_ListBox.Items.Add(“Started”)
[void] $Status_ListBox.Items.Add(“Prioritized”)
[void] $Status_ListBox.Items.Add(“Holding”)
[void] $Status_ListBox.Items.Add(“Finished”)
$Status_ListBox.Text = $editstatus;
$Status_ListBox.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
$formtaskedit.Controls.Add($Status_ListBox)

$total_complete_ListBox = New-Object System.Windows.Forms.ComboBox
$total_complete_ListBox.Location = New-Object System.Drawing.Size(540,390)
$total_complete_ListBox.Size = New-Object System.Drawing.Size(120,80)
$total_complete_ListBox.Height = 80

[void] $total_complete_ListBox.Items.Add(“0”)
[void] $total_complete_ListBox.Items.Add(“10”)
[void] $total_complete_ListBox.Items.Add(“20”)
[void] $total_complete_ListBox.Items.Add(“30”)
[void] $total_complete_ListBox.Items.Add(“40”)
[void] $total_complete_ListBox.Items.Add(“50”)
[void] $total_complete_ListBox.Items.Add(“60”)
[void] $total_complete_ListBox.Items.Add(“70”)
[void] $total_complete_ListBox.Items.Add(“80”)
[void] $total_complete_ListBox.Items.Add(“90”)
[void] $total_complete_ListBox.Items.Add(“100”)

$total_complete_ListBox.Text = $editporcentage;
$total_complete_ListBox.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
$formtaskedit.Controls.Add($total_complete_ListBox)

$Status_value = $Status_ListBox.SelectedItem.ToString();

$askby_ListBox = New-Object System.Windows.Forms.ComboBox
$askby_ListBox.Location = New-Object System.Drawing.Size(540,320)
$askby_ListBox.Size = New-Object System.Drawing.Size(120,80)
$askby_ListBox.Height = 80

[void] $askby_ListBox.Items.Add(“Admin”)
[void] $askby_ListBox.Items.Add(“Client”)
[void] $askby_ListBox.Items.Add(“Tech”)
[void] $askby_ListBox.Items.Add(“Audain”)

$askby_ListBox.Sorted = $true;
$askby_ListBox.Text = $editaskby;

$askby_ListBox.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
$formtaskedit.Controls.Add($askby_ListBox)

$x = $Status_ListBox.SelectedItem.ToString();

$complet_date_text_field = New-Object System.Windows.Forms.button
$complet_date_text_field.Location = New-Object System.Drawing.Size(540,110)
$complet_date_text_field.Size = New-Object System.Drawing.Size(120,30)
$complet_date_text_field.Text = $editcomplete
$complet_date_text_field.Add_Click({datepicker})
$formtaskedit.Controls.Add($complet_date_text_field)

$alert_text_field = New-Object System.Windows.Forms.textBox
$alert_text_field.Location = New-Object System.Drawing.Size(540,250)
$alert_text_field.Size = New-Object System.Drawing.Size(120,30)
$alert_text_field.text = $editalert
$alert_text_field.ReadOnly = $true
$formtaskedit.Controls.Add($alert_text_field)

#Afficher bouton search
$saveButton = New-Object System.Windows.Forms.Button
$saveButton.Location = New-Object System.Drawing.Size(10,460)
$saveButton.Size = New-Object System.Drawing.Size(100,23)
$saveButton.Text = “Save”
$saveButton.Add_Click({saveedit})

$formtaskedit.Controls.Add($saveButton)

#Afficher bouton quitter
$quitButton = New-Object System.Windows.Forms.Button
$quitButton.Location = New-Object System.Drawing.Size(130,460)
$quitButton.Size = New-Object System.Drawing.Size(100,23)
$quitButton.Text = “Close”
$QuitButton.Add_Click(({$formtaskedit.Close()}))
$formtaskedit.Controls.Add($quitButton)

#Démarer le formulaire
#Show form
$formtaskedit.Topmost = $True

[void] $formtaskedit.ShowDialog()
$List.SelectedItems.text
}

Function saveedit {

$procs = Import-csv “c:\temp\UsersList.csv” -encoding UTF7
$task = $List.SelectedItems.text
foreach ($row in $procs ) {
if ($row.task -eq $task) {
$row.task = $task_text_field.text
$row.note = $add_note_text_field.text
$row.priority = $priority_ListBox.SelectedItem.ToString()
$row.status = $Status_ListBox.SelectedItem.ToString()
$row.pourcentage = $total_complete_ListBox.SelectedItem.ToString()
$row.askby = $askby_ListBox.SelectedItem.ToString()
}
}
$procs | Export-Csv “c:\temp\UsersList.csv” -NoTypeInformation
$formtaskedit.Close()
refreshmoi

}
Function taskcomplete {
$procs = Import-csv “c:\temp\UsersList.csv” -encoding UTF7
$task = $List.SelectedItems.text
foreach ($row in $procs ) {
if ($row.task -eq $task) {
$row.status = “Complete”
$row.pourcentage = “100”
$row.date_complete = Get-Date
}
}
$procs | Export-Csv “c:\temp\UsersList.csv” -NoTypeInformation
refreshmoi
}

Function refreshmoi {
[System.Windows.Forms.MessageBox]::Show(“Task Saved successfully”,”Message”,1)

$procs = Import-csv “c:\temp\UsersList.csv”
AddData $procs $list

}

# Debut du script
$form = New-Object System.Windows.Forms.Form

$Form = New-Object System.Windows.Forms.Form
$form.Text = “Task Manager”
$Form.Size = New-Object System.Drawing.Size(300,150)
$Form.StartPosition = “CenterScreen”
$form.Font = New-Object System.Drawing.Font(“Segoe UI”,10)
$Form.Width = 1280
$Form.Height = 850

# Add task button to list
$btnaddtask = New-Object System.Windows.Forms.Button
$btnaddtask.TabIndex = 1
$btnaddtask.Name = “btnaddtask”
$btnaddtask.Size = New-Object System.Drawing.Size(100,30)
$btnaddtask.Text = “Add Task”
$btnaddtask.Location = New-Object System.Drawing.Size(10,10)
$btnaddtask.add_Click({newtask})
$form.Controls.Add($btnaddtask)

# Add note button
$btnaddnote = New-Object System.Windows.Forms.Button
$btnaddnote.TabIndex = 2
$btnaddnote.Name = “btnaddnote”
$btnaddnote.Size = New-Object System.Drawing.Size(100,30)
$btnaddnote.Text = “Edit”
$btnaddnote.Location = New-Object System.Drawing.Size(120,10)
$btnaddnote.add_Click({itemselect})
$form.Controls.Add($btnaddnote)

# Complete button
$btncomplete = New-Object System.Windows.Forms.Button
$btncomplete.TabIndex = 3
$btncomplete.Name = “btncomplete”
$btncomplete.Size = New-Object System.Drawing.Size(160,30)
$btncomplete.Text = “Set task as Complete”
$btncomplete.Location = New-Object System.Drawing.Size(230,10)
$btncomplete.add_Click({taskcomplete})
$form.Controls.Add($btncomplete)

# Add alert button
$btnalert = New-Object System.Windows.Forms.Button
$btnalert.TabIndex = 4
$btnalert.Name = “btnalert”
$btnalert.Size = New-Object System.Drawing.Size(160,30)
$btnalert.Text = “Add new alert”
$btnalert.Location = New-Object System.Drawing.Size(400,10)
$btnalert.add_Click($btnalert_OnClick)
$form.Controls.Add($btnalert)

# Set Priority button
$btnPriority = New-Object System.Windows.Forms.Button
$btnPriority.TabIndex = 5
$btnPriority.Name = “btnPriority”
$btnPriority.Size = New-Object System.Drawing.Size(160,30)
$btnPriority.Text = “Set Priority”
$btnPriority.Location = New-Object System.Drawing.Size(570,10)
$btnPriority.add_Click($btnPriority_OnClick)
$form.Controls.Add($btnPriority)

# Quit button
$btnquit = New-Object System.Windows.Forms.Button
$btnquit.TabIndex = 6
$btnquit.Name = “btnquit”
$btnquit.Size = New-Object System.Drawing.Size(100,30)
$btnquit.Text = “Quit”
$btnquit.Location = New-Object System.Drawing.Size(1130,750)
$btnquit.add_Click({$form.Close()})
$form.Controls.Add($btnquit)

# List All button
$btnlistall = New-Object System.Windows.Forms.Button
$btnlistall.TabIndex = 7
$btnlistall.Name = “btnlistall”
$btnlistall.Size = New-Object System.Drawing.Size(100,30)
$btnlistall.Text = “List All”
$btnlistall.Location = New-Object System.Drawing.Size(10,750)
$btnlistall.add_Click($btnlistall_OnClick)
$form.Controls.Add($btnlistall)

# all actif button
$btnlistactif = New-Object System.Windows.Forms.Button
$btnlistactif.TabIndex = 8
$btnlistactif.Name = “btnlistactif”
$btnlistactif.Size = New-Object System.Drawing.Size(200,30)
$btnlistactif.Text = “List Actif only”
$btnlistactif.Location = New-Object System.Drawing.Size(120,750)
$btnlistactif.add_Click($btnlistactif_OnClick)
$form.Controls.Add($btnlistactif)

# search button
$btnSearch = New-Object System.Windows.Forms.Button
$btnSearch.TabIndex = 9
$btnSearch.Name = “btnSearch”
$btnSearch.Size = New-Object System.Drawing.Size(60,30)
$btnSearch.Text = “Search”
$btnSearch.Location = New-Object System.Drawing.Size(800,10)
$btnSearch.add_Click($btnSearch_OnClick)
$form.Controls.Add($btnSearch)

#Search field
$searchboxBox = New-Object System.Windows.Forms.TextBox
$searchboxBox.Location = New-Object System.Drawing.Size(880,10)
$searchboxBox.Size = New-Object System.Drawing.Size(340,30)
$form.Controls.Add($searchboxBox)

$list = New-Object System.Windows.Forms.ListView
$list.TabIndex = 11

$list.Width = 1220
$list.Height = 660
$list.Location = ‘10,68’
$list.View = “Details”
$list.GridLines = $true
$list.FullRowSelect = $true
$list.AllowColumnReorder = $true
$list.Scrollable = $true
$list.Sorting =’None’
$list.add_ColumnClick({SortList $_.Column})
# $List.LabelEdit = $true

$form.Controls.Add($list)

# Add data to the list box
$procs = Get-Process

# Create our own tag object to be saved in each column
# This will allow us to determine the column currently sorting and its direction
$tag = New-Object -TypeName PSCustomObject -Property @{
sortOrder = [System.Windows.Forms.SortOrder]::Ascending
}

# Create the columns
$col = $list.Columns.Add(“Task”, 580)
$col.Tag = $tag
$col = $list.Columns.Add(“Creation Date”, 100)
$col.Tag = $tag
$col = $list.Columns.Add(“Date Complete”, 100)
$col.Tag = $tag
$col = $list.Columns.Add(“Status”, 60)
$col.Tag = $tag
$col = $list.Columns.Add(“Alert”, 50)
$col.Tag = $tag
$col = $list.Columns.Add(“Note”, 60)
$col.Tag = $tag
$col = $list.Columns.Add(“Ask By”, 130)
$col.Tag = $tag
$col = $list.Columns.Add(“Priority”, 100)
$col.Tag = $tag
$col = $list.Columns.Add(“%”, 100)
$col.Tag = $tag

# Add data to the list box

$procs = Import-csv “c:\temp\UsersList.csv” -encoding UTF7

AddData $procs $list

#$OnResize =
#{
# $size = New-Object System.Drawing.Size
# $size.Width = $form.Width – 15
# $size.Height = $form.Height – 93
# $list.Size = $size
#}
#$form.add_Resize($OnResize)

#Rock ‘n roll
$form.ShowDialog()| Out-Null