Slt,

Je cherche désespérement à envoyer dans une listbox, la liste de tous mes noms de pc sous mon ad.

J'ai ma liste :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
Get-ADComputer -Filter {objectclass -eq 'computer'} | Format-Table name
Ma listbox :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
$listBox1.FormattingEnabled = $True
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 268
$System_Drawing_Size.Height = 355
$listBox1.Size = $System_Drawing_Size
$listBox1.DataBindings.DefaultDataSourceUpdateMode = 0
$listBox1.Name = "Listes des ordis AD"
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 12
$System_Drawing_Point.Y = 9
$listBox1.Location = $System_Drawing_Point
$listBox1.TabIndex = 0
Et mon ajout d'info dans la listbox ne marche pas :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
$liste_ordi = get-ADComputer -Filter {objectclass -eq 'computer'} | Format-Table name 
foreach ($i in $liste_ordi) {
$form1.Controls.Add($i)
    }
L'erreur suivante apparait :

«*Impossible de convertir la valeur «*Microsoft.PowerShell.Commands.Internal.Format.Forma
tEntryData*» du type «*Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData*» en type «*System.Windows.Forms.Control*».*»
Merci de votre aide