Bonjour à tous,
je prépare un script PowerShell GUI que voici et je bloque sur certain point.
Code PowerShell : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75 ]Import-Module ActiveDirectory Add-Type -assembly System.Windows.Forms $main_form = New-Object System.Windows.Forms.Form $main_form.Text ='GUI' $main_form.Width = 600 $main_form.Height = 400 $main_form.AutoSize = $true $Label = New-Object System.Windows.Forms.Label $Label.Text = "Utilisateurs AD" $Label.Location = New-Object System.Drawing.Point (0,10) $Label.AutoSize = $true $main_form.Controls.Add($Label) $ComboBox = New-Object System.Windows.Forms.ComboBox $ComboBox.Width = 300 $Users = get-aduser -filter * -SearchBase "OU=xx,DC=xx,DC=lan" -Properties SamAccountName Foreach ($User in $Users) { $ComboBox.Items.Add($User.Name + "|" + $User.SamAccountName ); } $ComboBox.Location = New-Object System.Drawing.Point (90,10) $ComboBox.KeyUp = $prenom.Text='ok' $main_form.Controls.Add($ComboBox) $Label1 = New-Object System.Windows.Forms.Label $Label1.Text = "Nom" $Label1.Location = New-Object System.Drawing.Point (0,40) $Label1.AutoSize = $true $main_form.Controls.Add($Label1) $nom = New-Object System.Windows.Forms.TextBox $nom.Width = 300 $nom.Location = New-Object System.Drawing.Point (90,40) $nom.CharacterCasing='Upper' $main_form.Controls.Add($nom) $Label2 = New-Object System.Windows.Forms.Label $Label2.Text = "Prenom" $Label2.Location = New-Object System.Drawing.Point (0,60) $Label2.AutoSize = $true $main_form.Controls.Add($Label2) $prenom = New-Object System.Windows.Forms.TextBox $prenom.Width = 300 $prenom.Location = New-Object System.Drawing.Point (90,60) $main_form.Controls.Add($prenom) $Label4 = New-Object System.Windows.Forms.Label $Label4.Text = "login" $Label4.Location = New-Object System.Drawing.Point (0,80) $Label4.AutoSize = $true $main_form.Controls.Add($Label4) $login = New-Object System.Windows.Forms.TextBox $login.Width = 300 $login.Location = New-Object System.Drawing.Point (90,80) $main_form.Controls.Add($login) $Label3 = New-Object System.Windows.Forms.Label $Label3.Text = "Email" $Label3.Location = New-Object System.Drawing.Point (0,100) $Label3.AutoSize = $true $main_form.Controls.Add($Label3) $email = New-Object System.Windows.Forms.TextBox $email.Width = 300 $email.Location = New-Object System.Drawing.Point (90,100) $main_form.Controls.Add($email) $main_form.ShowDialog()
Sur la zone Combox (liste déroulante), une fois l'utilisateur sélectionné, je voudrais récupérer les informations de AD et qu'il les inscrits dans les champs Prenom/nom (champs Textbox du script)
Mais avant çaje voudrais déjà arriver une fois la sélection faite, inscrire un texte dans un des champs textbox du script.
Est-ce réalisable? J'étais partie sur le KeyUp, mais je ne sais pas comment le formuler dans mon script
Code PowerShell : Sélectionner tout - Visualiser dans une fenêtre à part ]$ComboBox.KeyUp = $prenom.Text='ok'
Merci d'avance pour vos conseils
Partager