Question
Modification de variable
- COTTIN
- Auteur du sujet
- Hors Ligne
- Membre premium
-
Réduire
Plus d'informations
- Messages : 84
- Remerciements reçus 0
il y a 13 ans 6 mois #13104
par COTTIN
Modification de variable a été créé par COTTIN
Bonjour,
Je vous expose mon problème:
Je récupère des info de ma salle serveur (environ 60 serveurs)
J'ai un HIC.
Quand je récupère les infos de mes serveurs j'ai la page suivante
M[code:1]otherBoard Information
Name Manufacturer Product SerialNumber Status
Carte de base Dell Inc. 0J250G ..CN1374085M019A.
System Information
Vendor Version Name IdentifyingNumber UUID
Dell Inc. PowerEdge 2950 4Y9YQ3J 4C4C4544-0059-3910-8059-B4C04F51334A
Harddisk Information
Model InterfaceType Size TotalTracks Partitions Status TotalCylinders
DELL PERC 6/i SCSI Disk Device SCSI 72744376320 2255220 3 OK 8844
PowerDevice by PowerPath SCSI 225479600640 6990315 1 OK 27413
PowerDevice by PowerPath SCSI 225479600640 6990315 1 OK 27413
PowerDevice by PowerPath SCSI 225479600640 6990315 1 OK 27413
PowerDevice by PowerPath SCSI 53686402560 1664385 1 OK 6527
PowerDevice by PowerPath SCSI 53686402560 1664385 1 OK 6527
PowerDevice by PowerPath SCSI 53686402560 1664385 1 OK 6527
Physical Memory Information
DeviceLocator Capacity Speed
DIMM1 4294967296 667
DIMM2 4294967296 667
DIMM3 4294967296 667
DIMM4 4294967296 667
DIMM5 2147483648 667
DIMM6 2147483648 667
DIMM7 2147483648 667
DIMM8 2147483648 667[/code:1]
J'aimerais que la variable SIZE soit en Go.
mon Script :
[code:1]#############initialisation des variables#############
cd \"U:\Script\pageweb\"
$filepath = \"U:\Script\pageweb\"
############# HTML Output Formatting #############
$a = \"<!--mce:0-->\"
######Initialisation du credential#############
$chaine_chiffree = Get-Content U:\Script\pageweb\joind_dom.txt
$cle = Get-Content U:\Script\pageweb\cle.txt
$password = convertTo-SecureString -key $cle -String $chaine_chiffree
$user = \"***\"
$credential = New-Object -typename System.Management.Automation.PsCredential -ArgumentList $user, $password
#############Lecture du fichier ligne/ligne#############
for ($i=1;$i -lt 42; $i++){ (Get-Content test.txt -totalcount $i)[-1] > tt.txt
$name = Get-Content tt.txt
ConvertTo-Html -Head $a -Title \"Hardware Information for $name\" -Body \"<h1> Computer Name : $name </h1>\" > \"$filepath\$name.html\"
#############MotherBoard: Win32_BaseBoard # You can Also select Tag,Weight,Width #############
Get-WmiObject -ComputerName $name Win32_BaseBoard -Credential $credential| Select Name,Manufacturer,Product,SerialNumber,Status | ConvertTo-html -Body \"<H2> MotherBoard Information</H2>\" >> \"$filepath\$name.html\"
############# System Info #############
Get-WmiObject Win32_ComputerSystemProduct -ComputerName $name -Credential $credential | Select Vendor,Version,Name,IdentifyingNumber,UUID | ConvertTo-html -Body \"<H2> System Information </H2>\" >> \"$filepath\$name.html\"
############# Hard-Disk #############
Get-WmiObject win32_diskDrive -ComputerName $name -Credential $credential | select Model,InterfaceType,Size,TotalTracks,Partitions,Status,TotalCylinders | ConvertTo-html -Body \"<H2> Harddisk Information </H2>\" >> \"$filepath\$name.html\"
############# Memory #############
Get-WmiObject Win32_PhysicalMemory -ComputerName $name -Credential $credential | select DeviceLocator,Capacity,Speed | ConvertTo-html -Body \"<H2> Physical Memory Information</H2>\" >> \"$filepath\$name.html\"
############# Invoke Expressons #############
invoke-Expression \"$filepath\$name.html\"
}[/code:1]
Merci de votre futur aide
Cordialement,<br><br>Message édité par: tcottin, à: 19/11/12 18:39
Je vous expose mon problème:
Je récupère des info de ma salle serveur (environ 60 serveurs)
J'ai un HIC.
Quand je récupère les infos de mes serveurs j'ai la page suivante
M[code:1]otherBoard Information
Name Manufacturer Product SerialNumber Status
Carte de base Dell Inc. 0J250G ..CN1374085M019A.
System Information
Vendor Version Name IdentifyingNumber UUID
Dell Inc. PowerEdge 2950 4Y9YQ3J 4C4C4544-0059-3910-8059-B4C04F51334A
Harddisk Information
Model InterfaceType Size TotalTracks Partitions Status TotalCylinders
DELL PERC 6/i SCSI Disk Device SCSI 72744376320 2255220 3 OK 8844
PowerDevice by PowerPath SCSI 225479600640 6990315 1 OK 27413
PowerDevice by PowerPath SCSI 225479600640 6990315 1 OK 27413
PowerDevice by PowerPath SCSI 225479600640 6990315 1 OK 27413
PowerDevice by PowerPath SCSI 53686402560 1664385 1 OK 6527
PowerDevice by PowerPath SCSI 53686402560 1664385 1 OK 6527
PowerDevice by PowerPath SCSI 53686402560 1664385 1 OK 6527
Physical Memory Information
DeviceLocator Capacity Speed
DIMM1 4294967296 667
DIMM2 4294967296 667
DIMM3 4294967296 667
DIMM4 4294967296 667
DIMM5 2147483648 667
DIMM6 2147483648 667
DIMM7 2147483648 667
DIMM8 2147483648 667[/code:1]
J'aimerais que la variable SIZE soit en Go.
mon Script :
[code:1]#############initialisation des variables#############
cd \"U:\Script\pageweb\"
$filepath = \"U:\Script\pageweb\"
############# HTML Output Formatting #############
$a = \"<!--mce:0-->\"
######Initialisation du credential#############
$chaine_chiffree = Get-Content U:\Script\pageweb\joind_dom.txt
$cle = Get-Content U:\Script\pageweb\cle.txt
$password = convertTo-SecureString -key $cle -String $chaine_chiffree
$user = \"***\"
$credential = New-Object -typename System.Management.Automation.PsCredential -ArgumentList $user, $password
#############Lecture du fichier ligne/ligne#############
for ($i=1;$i -lt 42; $i++){ (Get-Content test.txt -totalcount $i)[-1] > tt.txt
$name = Get-Content tt.txt
ConvertTo-Html -Head $a -Title \"Hardware Information for $name\" -Body \"<h1> Computer Name : $name </h1>\" > \"$filepath\$name.html\"
#############MotherBoard: Win32_BaseBoard # You can Also select Tag,Weight,Width #############
Get-WmiObject -ComputerName $name Win32_BaseBoard -Credential $credential| Select Name,Manufacturer,Product,SerialNumber,Status | ConvertTo-html -Body \"<H2> MotherBoard Information</H2>\" >> \"$filepath\$name.html\"
############# System Info #############
Get-WmiObject Win32_ComputerSystemProduct -ComputerName $name -Credential $credential | Select Vendor,Version,Name,IdentifyingNumber,UUID | ConvertTo-html -Body \"<H2> System Information </H2>\" >> \"$filepath\$name.html\"
############# Hard-Disk #############
Get-WmiObject win32_diskDrive -ComputerName $name -Credential $credential | select Model,InterfaceType,Size,TotalTracks,Partitions,Status,TotalCylinders | ConvertTo-html -Body \"<H2> Harddisk Information </H2>\" >> \"$filepath\$name.html\"
############# Memory #############
Get-WmiObject Win32_PhysicalMemory -ComputerName $name -Credential $credential | select DeviceLocator,Capacity,Speed | ConvertTo-html -Body \"<H2> Physical Memory Information</H2>\" >> \"$filepath\$name.html\"
############# Invoke Expressons #############
invoke-Expression \"$filepath\$name.html\"
}[/code:1]
Merci de votre futur aide
Cordialement,<br><br>Message édité par: tcottin, à: 19/11/12 18:39
Connexion ou Créer un compte pour participer à la conversation.
- xyz
- Hors Ligne
- Modérateur
-
Réduire
Plus d'informations
- Messages : 6311
- Remerciements reçus 69
il y a 13 ans 6 mois #13106
par xyz
Tutoriels PowerShell
Réponse de xyz sur le sujet Re:Modification de variable
Salut,
tcottin écrit:
[code:1]
$size=225479600640
$Size|Select @{Name=\"Size (GB«»)\";Expression={[math]::Round(($_/1GB«»),3)}}
[/code:1]<br><br>Message édité par: Laurent Dardenne, à: 19/11/12 20:16
tcottin écrit:
Adapte ceci :J'aimerais que la variable SIZE soit en Go.
[code:1]
$size=225479600640
$Size|Select @{Name=\"Size (GB«»)\";Expression={[math]::Round(($_/1GB«»),3)}}
[/code:1]<br><br>Message édité par: Laurent Dardenne, à: 19/11/12 20:16
Tutoriels PowerShell
Connexion ou Créer un compte pour participer à la conversation.
- COTTIN
- Auteur du sujet
- Hors Ligne
- Membre premium
-
Réduire
Plus d'informations
- Messages : 84
- Remerciements reçus 0
il y a 13 ans 6 mois #13109
par COTTIN
Réponse de COTTIN sur le sujet Re:Modification de variable
bonjour,
Ta solution fonctionne si on récupère la variable.
Le truc c'est que cette variable est définie dans win32_diskdrive.
Ta solution fonctionne si on récupère la variable.
Le truc c'est que cette variable est définie dans win32_diskdrive.
Connexion ou Créer un compte pour participer à la conversation.
- xyz
- Hors Ligne
- Modérateur
-
Réduire
Plus d'informations
- Messages : 6311
- Remerciements reçus 69
il y a 13 ans 6 mois #13110
par xyz
Tutoriels PowerShell
Réponse de xyz sur le sujet Re:Modification de variable
J'ai supposé que tu penserais à l'adapter :
[code:1]
$Size=@{Name=\"Size (GB«»)\";Expression={[math]::Round(($_.Size/1GB«»),3)}}
Get-WmiObject win32_diskDrive |
select Model,InterfaceType,$Size,TotalTracks,Partitions,Status,TotalCylinders
[/code:1]
[code:1]
$Size=@{Name=\"Size (GB«»)\";Expression={[math]::Round(($_.Size/1GB«»),3)}}
Get-WmiObject win32_diskDrive |
select Model,InterfaceType,$Size,TotalTracks,Partitions,Status,TotalCylinders
[/code:1]
Tutoriels PowerShell
Connexion ou Créer un compte pour participer à la conversation.
- COTTIN
- Auteur du sujet
- Hors Ligne
- Membre premium
-
Réduire
Plus d'informations
- Messages : 84
- Remerciements reçus 0
il y a 13 ans 6 mois #13112
par COTTIN
Réponse de COTTIN sur le sujet Re:Modification de variable
le boulet tu connais, c'est moi.
Merci bien c'est parfait
Merci bien c'est parfait
Connexion ou Créer un compte pour participer à la conversation.
- xyz
- Hors Ligne
- Modérateur
-
Réduire
Plus d'informations
- Messages : 6311
- Remerciements reçus 69
il y a 13 ans 6 mois #13114
par xyz
Tutoriels PowerShell
Réponse de xyz sur le sujet Re:Modification de variable
tcottin écrit:
\"On pardonne tout à qui ne se pardonne rien.\"le boulet tu connais, c'est moi.
Tutoriels PowerShell
Connexion ou Créer un compte pour participer à la conversation.
Temps de génération de la page : 0.044 secondes
- Vous êtes ici :
-
Accueil
-
forum
-
PowerShell
-
Entraide pour les débutants
- Modification de variable