Question Regrouper Plusieurs Command en un Script

Plus d'informations
il y a 13 ans 8 mois #12399 par kevin
Bonjour,

je suis tout nouveau dans le script.
J'ai réaliser plusieurs petit script qui me donne des informations tel-que :

1er Script:
[code:1] param ([String]$ComputerName = '.')

$infos = Get-WmiObject Win32_OperatingSystem -ComputerName $ComputerName

$infos.csdversion[/code:1]

2em Script:
[code:1]########################################################################################################################
#
#
#
# Vérification du Driver Graphique
# Rechercher de clé de registre Pour le Driver SVGA :
# Recherchez l'emplacement suivant dans le Registre :
# HKEY_LOCAL_MACHINE\hardware\DeviceMap\Video
# La valeur Device\Video0 pointe vers une clé de Registre
# qui indique l'emplacement du pilote vidéo dont le chargement a été spécifié dans la configuration de Windows.
# Dans notre cas il pointe sur :
# HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Video\{2CCB54A8-560A-4837-923C-BCD5CD62B2EC}\0000
# puis le fichier: InstalledDisplayDrivers
#
########################################################################################################################


$a = get-itemproperty -path registry::\"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Video\{2CCB54A8-560A-4837-923C-BCD5CD62B2EC}\0000\"
$a.InstalledDisplayDrivers

# va sortir le driver Utiliser![/code:1]

3em Script
[code:1]$freemem = Get-WmiObject -Class Win32_OperatingSystem

# écrit mémoire Total sur mon PC/Server

\"Total Memoire (GB«»): {0}\" -f ([math]::round(($freemem.TotalVisibleMemorySize / 1024 / 1024), 2))
[/code:1]

puis 4eme Script
[code:1]########################################################################################################################
#
#
# Carte Réseau
#
#
########################################################################################################################


$a = get-itemproperty -path registry::\"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\C2A6F2EFE6910124C940B2B12CF170FE\InstallProperties\"
$a.DisplayName

# va sortir le driver Utiliser![/code:1]

puis 5eme
[code:1]########################################################################################################################
#
#
# Carte Réseau
#
#
########################################################################################################################


$a = get-itemproperty -path registry::\"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\C2A6F2EFE6910124C940B2B12CF170FE\InstallProperties\"
$a.DisplayVersion

# va sortir le driver Utiliser![/code:1]

puis 6eme
[code:1]wmic path Win32_Processor get SocketDesignation[/code:1]

puis 7eme
[code:1]
param ([String]$ComputerName = '.')

$infos = Get-WmiObject Win32_OperatingSystem -ComputerName $ComputerName

$infos.caption


[/code:1]

puis 8eme
[code:1]########################################################################################################################
#
#
# Carte Réseau
#
#
########################################################################################################################


$a = get-itemproperty -path registry::\"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\7\"
$a.Description

# va sortir le driver Utiliser![/code:1]

puis 9eme
[code:1]param ([String]$ComputerName = '.')
$lang = (Get-WmiObject Win32_OperatingSystem -ComputerName $ComputerName).oslanguage
$switch = switch ($lang) `
{
1033 {\"English\"};
1036 {\"French\"};
default {\"Unknown\"}
}
$switch[/code:1]

puis 10eme
[code:1]if ([intptr]::«»size -eq 8)
{
write-output '64 bits'
}
elseif ([intptr]::«»size -eq 4)
{
write-output '32 bits'
}
else
{
write-output 'OS ni 32, ni 64 bits !'
} [/code:1]

je voudrais rassemblé tout ces petits scripts en un script.

Merci d'avance de votre aide

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 13 ans 8 mois #12401 par Richard Lazaro
Bonjour,

Je te conseille de regarder les fonctions et le dotsourcing :
Get-Help about_functions
Get-Help about_functions_
mctexpert.blogspot.fr/2011/04/dot-sourci...wershell-script.html

Bien Cordialement,
Richard Lazaro.

Think-MS : (Get-Life).Days | %{ Learn-More }

\\"Problems cannot be solved by the same level of thinking that created them.\\" - Albert Einstein

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 13 ans 8 mois #12427 par kevin
j'ai regardé les fonctions que tu ma conseillé mais sans succès je trouve pas la solution pour rassemblé mes scripts en un seul script .

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 13 ans 8 mois #12428 par SiSMik
Bonjour,

Regrouper des scripts est en soit simple.

[code:1]$infos = Get-WmiObject Win32_OperatingSystem -ComputerName .
$infos.csdversion
$infos.caption

$a = get-itemproperty -path registry::\"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Video\{2CCB54A8-560A-4837-923C-BCD5CD62B2EC}\0000\"
$a.InstalledDisplayDrivers

$freemem = Get-WmiObject -Class Win32_OperatingSystem
\"Total Memoire (GB«»): {0}\" -f ([math]::round(($freemem.TotalVisibleMemorySize / 1024 / 1024), 2))

$a = get-itemproperty -path registry::\"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\C2A6F2EFE6910124C940B2B12CF170FE\InstallProperties\"
$a.DisplayName
$a.DisplayVersion

wmic path Win32_Processor get SocketDesignation

$a = get-itemproperty -path registry::\"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\7\"
$a.Description

$lang = (Get-WmiObject Win32_OperatingSystem -ComputerName .).oslanguage
$switch = switch ($lang) `
{
1033 {\"English\"};
1036 {\"French\"};
default {\"Unknown\"}
}
$switch

if ([intptr]::«»size -eq 8) { write-output '64 bits' }
elseif ([intptr]::«»size -eq 4) { write-output '32 bits' }
else { write-output 'OS ni 32, ni 64 bits !' } [/code:1]

Cependant prendre des script à droite et à gauche pour en faire un unique, m'est avis que c'est un bon début, mais si vous n'arrivez pas à les concaténer, c'est que vous ne les comprenez pas.
Je vous renvois aux liens de Richard, avec le code que je vous ai posté plus haut, vous verrez que [code:1]param ([String]$ComputerName = '.')[/code:1]
ne peut être appelé qu'en début de script ou en début de fonction.

Bien cordialement,

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 13 ans 8 mois #12429 par kevin
Ok merci beaucoup.
J'ai fais tout les petites script maintenant je vais en faire un grand.

Connexion ou Créer un compte pour participer à la conversation.

Temps de génération de la page : 0.049 secondes
Propulsé par Kunena