Bonjour,
Je suis actuellement en entreprise et nous allons prochainement changer tous les postes informatique. Acutellement sous windows 7, ces nouveaux postes seront sous windows 10.
Je débute tout juste en script PowerShell, j'aimerais créer une interface permettant à un utilisateur lors de sa première connexion de décider (de manière interactive) quelles données de son profil utilisateur il souhaite conserver. Ainsi les données qui ne sont pas utiles seront supprimées afin d'alléger les serveurs.
J'ai commencé à faire l'interface graphique (voir ci-dessous), j'aimerais si possible des indications sur la marche à suivre concernant l'écriture d'un script powershell tenant comptes des différentes données utilisateurs et permettant de supprimer ou de conserver les données selon la réponse de l'user sur l'interface.
Merci d'avance!
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 [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") Add-Type AssemblyName System.Windows.Forms $MainForm = New-Object System.Windows.Forms.Form $MainForm.StartPosition = "CenterScreen" $MainForm.Width = 750 $MainForm.Height = 500 $MainForm.Text = "Conservation de vos données: Windows 7 -> Windows 10." $label_prez = New-Object System.Windows.Forms.Label $label_prez.Location = New-Object System.Drawing.Point(18,430) $label_prez.Size = New-Object System.Drawing.Size(170,200) $label_prez.Text = "Passage W7 to W10" $MainForm.Controls.add($label_prez) $label_q = New-Object System.Windows.Forms.Label $label_q.Location = New-Object System.Drawing.Point(315,260) $label_q.Size = New-Object System.Drawing.Size(150,50) $label_q.Text = "Conserver ces données?" $label_q.Font = New-Object System.Drawing.Font("Arial",10,[System.Drawing.FontStyle]::Italic) $MainForm.Controls.add($label_q) $button_oui = New-Object System.Windows.Forms.Button $button_oui.Location = New-Object System.Drawing.Size(240,320) $button_oui.Text = "Oui" $button_oui.Size = New-Object System.Drawing.Size(100,50) $button_oui.Name = 'button_ok' $MainForm.Controls.Add($button_oui) $file1 = (get-item 'C:\Users\Elias\W.png') $img = [System.Drawing.Image]::FromFile($file1); [System.Windows.Forms.Application]::EnableVisualStyles(); $pictureBox = new-object Windows.Forms.PictureBox $pictureBox.Width = $img.Size.Width; $pictureBox.Height = $img.Size.Height; $pictureBox.Image = $img; $MainForm.controls.add($pictureBox) $button_non = New-Object System.Windows.Forms.Button $button_non.Location = New-Object System.Drawing.Size(380,320) $button_non.Text = "Non" $button_non.Size = New-Object System.Drawing.Size(100,50) $button_non.Name = 'button_non' $MainForm.Controls.Add($button_non) $MainForm.Add_Shown({$MainForm.Activate()}) $MainForm.ShowDialog()
Partager