Bonjour,
je souhaites lire une variable d'environnement présente sur un nombre de postes précis.
Je dispose déjà d'un script qui lui, lit une clé de registre. La liste de poste est dans un .csv.
J'utilise une boucle for each mais cela ne fonctionne pas. Il écrit en sortie (un fichier Html) la même valeur pour tous les postes..
Je vous met ici le code :
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105 ##################Define variables######################################## ############################################################################ $report = "C:\scripts\report.htm" $servers = Get-content C:\scripts\test.txt $checkrep = Test-Path $report If ($checkrep -like "True") { Remove-Item "C:\scripts\report.htm" } New-Item "C:\scripts\report.htm" -type file ################################ADD HTML Content############################# Add-Content $report "<html>" Add-Content $report "<head>" Add-Content $report "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>" Add-Content $report '<title>Serveurs de licences SOLIDWORKS</title>' add-content $report '<STYLE TYPE="text/css">' add-content $report "<!--" add-content $report "td {" add-content $report "font-family: Tahoma;" add-content $report "font-size: 11px;" add-content $report "border-top: 1px solid #999999;" add-content $report "border-right: 1px solid #999999;" add-content $report "border-bottom: 1px solid #999999;" add-content $report "border-left: 1px solid #999999;" add-content $report "padding-top: 0px;" add-content $report "padding-right: 0px;" add-content $report "padding-bottom: 0px;" add-content $report "padding-left: 0px;" add-content $report "}" add-content $report "body {" add-content $report "margin-left: 5px;" add-content $report "margin-top: 5px;" add-content $report "margin-right: 0px;" add-content $report "margin-bottom: 10px;" add-content $report "" add-content $report "table {" add-content $report "border: thin solid #000000;" add-content $report "}" add-content $report "-->" add-content $report "</style>" Add-Content $report "</head>" Add-Content $report "<body>" add-content $report "<table width='50%'>" add-content $report "<tr bgcolor='Lavender'>" add-content $report "<td colspan='7' height='25' align='center'>" #######################Title of table#################################################### add-content $report "<font face='tahoma' color='#003399' size='4'><strong>Serveurs de licences SOLIDWORKS</strong></font>" add-content $report "</td>" add-content $report "</tr>" add-content $report "</table>" ######################Definae Columns################################################### add-content $report "<table width='50%'>" Add-Content $report "<tr bgcolor='Lavender'>" Add-Content $report "<td width='10%' align='center'><B>Workstations</B></td>" Add-Content $report "<td width='10%' align='center'><B>Serveur de licences</B></td>" Add-Content $report "</tr>" #####Get Registry Value #### foreach ($Server in $servers) { $Value = (Get-Item env:\maVariableEnv).value ######################Add values inside Columns######################################## Add-Content $report "<tr>" Add-Content $report "<td bgcolor= 'GainsBoro' align=center><B>$Server</B></td>" Add-Content $report "<td bgcolor= 'Aquamarine' align=center><B>$Value</B></td>" Add-Content $report "</tr>" } #####################Close HTMl Tables############################################### Add-content $report "</table>" Add-Content $report "</body>" Add-Content $report "</html>" #############################################################################################
Je sèche... je pense que tout est dans la boucle ou comment est lu cette variable ?
Avez vous une idée d'adaptation pour réussir a lire cette variable d'environnement ?
Merci !!
Partager