Bonjour, je suis bloqué dans un form sous powershell.
Je dois faire afficher le résultat d'une fonction dans ma textbox, mais je vois pas trop comment faire ..
Voici le code de ma form:
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 Add-Type -AssemblyName System.Windows.Forms [System.Windows.Forms.Application]::EnableVisualStyles() $mon_form = New-Object System.Windows.Forms.Form $mon_form.Text = 'Titre de mon logiciel' $mon_form.Width = 600 $mon_form.Height = 400 $mon_form.AutoSize = $true $Button = New-Object System.Windows.Forms.Button $Button.Location = New-Object System.Drawing.Size(10,10) $Button.Size = New-Object System.Drawing.Size(120,23) $Button.Text = "Duplicatas" $Button.Add_Click({function button{ & 'C:\DossierTP3\ScriptHash.ps1'}}) $mon_form.Controls.Add($Button) $textBox = New-Object System.Windows.Forms.TextBox $textBox.Location = New-Object System.Drawing.Point(40,10) $textBox.Size = New-Object System.Drawing.Size(360,200) $textBox.Multiline = $True $textBox.ScrollBars = "Vertical" $mon_form.Controls.Add($textBox) $mon_form.ShowDialog()
Voici le code mon script hash dont je fais appel dans ma fonction:
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 cd 'C:\DossierTP3' $arborescence = dir -r | % { if ($_.PsIsContainer) { $_.FullName + "\" } else { $_.FullName } } $mes_hash = dir -r | Get-FileHash | Select-Object Hash, Path $duplicatas = @{} $fichierDouble = @{} foreach ($hash in $mes_hash) { if ($duplicatas.ContainsKey($hash.Hash)){ Write-Host "Voici les fichiers dupliqués: $hash" }else{ $duplicatas.Add($hash.Hash,$hash.Path) } } $duplicatas
Si vous avez une solution, je suis preneurMerci !
Partager