Question
Accès distant au registre avec WMI
- Melmann
- Auteur du sujet
- Hors Ligne
- Nouveau membre
-
Réduire
Plus d'informations
- Messages : 1
- Remerciements reçus 0
il y a 15 ans 10 mois #6880
par Melmann
Accès distant au registre avec WMI a été créé par Melmann
Bonjour à tous,
Je suis en train de développer un petit script qui doit me permettre de lister tout le contenu de HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall sur chaque machine de notre domaine afin de récupérer toutes les applications installées.
Je ne trouve malheureusement pas le moyen d'accéder a distance au registre des machines en utilisant WMI.
Quelqu'un peut-il m'aider ?
Merci d'avance et à bientôt.
Je suis en train de développer un petit script qui doit me permettre de lister tout le contenu de HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall sur chaque machine de notre domaine afin de récupérer toutes les applications installées.
Je ne trouve malheureusement pas le moyen d'accéder a distance au registre des machines en utilisant WMI.
Quelqu'un peut-il m'aider ?
Merci d'avance et à bientôt.
Connexion ou Créer un compte pour participer à la conversation.
- brutosaure
- Hors Ligne
- Membre senior
-
Réduire
Plus d'informations
- Messages : 59
- Remerciements reçus 0
il y a 15 ans 10 mois #6924
par brutosaure
Réponse de brutosaure sur le sujet Re:Accès distant au registre avec WMI
Regarde du côté de [code:1][microsoft.win32.registrykey]::openremotebasekey[/code:1]
J'ai trouvé cet exemple, si ca peut t'aider
[code:1]
##############################################################################
##
## Get-RemoteRegistryKeyProperty.ps1
##
## Get the value of a remote registry key property
##
## ie:
##
## PS >$registryPath =
## \"HKLM:\software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell\"
## PS >Get-RemoteRegistryKeyProperty LEE-DESK $registryPath \"ExecutionPolicy\"
##
##############################################################################
param(
$computer = $(throw \"Please specify a computer name.\"«»),
$path = $(throw \"Please specify a registry path\"«»),
$property = \"*\"
)
## Validate and extract out the registry key
if($path -match \"^HKLM:\\(.*)\"«»)
{
$baseKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(
\"LocalMachine\", $computer)
}
elseif($path -match \"^HKCU:\\(.*)\"«»)
{
$baseKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(
\"CurrentUser\", $computer)
}
else
{
Write-Error (\"Please specify a fully-qualified registry path \" +
\"(i.e.: HKLM:\Software) of the registry key to open.\"«»)
return
}
## Open the key
$key = $baseKey.OpenSubKey($matches[1])
$returnObject = New-Object PsObject
## Go through each of the properties in the key
foreach($keyProperty in $key.GetValueNames())
{
## If the property matches the search term, add it as a
## property to the output
if($keyProperty -like $property)
{
$returnObject |
Add-Member NoteProperty $keyProperty $key.GetValue($keyProperty)
}
}
## Return the resulting object
$returnObject
## Close the key and base keys
$key.Close()
$baseKey.Close()
[/code:1]<br><br>Message édité par: brutosaure, à: 20/05/10 16:29
J'ai trouvé cet exemple, si ca peut t'aider
[code:1]
##############################################################################
##
## Get-RemoteRegistryKeyProperty.ps1
##
## Get the value of a remote registry key property
##
## ie:
##
## PS >$registryPath =
## \"HKLM:\software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell\"
## PS >Get-RemoteRegistryKeyProperty LEE-DESK $registryPath \"ExecutionPolicy\"
##
##############################################################################
param(
$computer = $(throw \"Please specify a computer name.\"«»),
$path = $(throw \"Please specify a registry path\"«»),
$property = \"*\"
)
## Validate and extract out the registry key
if($path -match \"^HKLM:\\(.*)\"«»)
{
$baseKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(
\"LocalMachine\", $computer)
}
elseif($path -match \"^HKCU:\\(.*)\"«»)
{
$baseKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(
\"CurrentUser\", $computer)
}
else
{
Write-Error (\"Please specify a fully-qualified registry path \" +
\"(i.e.: HKLM:\Software) of the registry key to open.\"«»)
return
}
## Open the key
$key = $baseKey.OpenSubKey($matches[1])
$returnObject = New-Object PsObject
## Go through each of the properties in the key
foreach($keyProperty in $key.GetValueNames())
{
## If the property matches the search term, add it as a
## property to the output
if($keyProperty -like $property)
{
$returnObject |
Add-Member NoteProperty $keyProperty $key.GetValue($keyProperty)
}
}
## Return the resulting object
$returnObject
## Close the key and base keys
$key.Close()
$baseKey.Close()
[/code:1]<br><br>Message édité par: brutosaure, à: 20/05/10 16:29
Connexion ou Créer un compte pour participer à la conversation.
- brutosaure
- Hors Ligne
- Membre senior
-
Réduire
Plus d'informations
- Messages : 59
- Remerciements reçus 0
il y a 15 ans 10 mois #6925
par brutosaure
Réponse de brutosaure sur le sujet Re:Accès distant au registre avec WMI
Ici une exemple de modification de key
[code:1]
$server=ton_server
$hkey=currentuser
$pathkey=\"software\microsoft\windows\currentversion\internet settings\"
$key=\"ProxyEnable\"
$value=\"1\"
$remote=[microsoft.win32.registrykey]::openremotebasekey($hkey,\"$server\")
$remotekey=$remote.OpenSubKey($pathkey,$true)
$remotekey.setvalue($key,$value)
[/code:1]
Message édité par: brutosaure, à: 20/05/10 16:38
Message édité par: brutosaure, à: 20/05/10 16:39<br><br>Message édité par: brutosaure, à: 20/05/10 16:40
[code:1]
$server=ton_server
$hkey=currentuser
$pathkey=\"software\microsoft\windows\currentversion\internet settings\"
$key=\"ProxyEnable\"
$value=\"1\"
$remote=[microsoft.win32.registrykey]::openremotebasekey($hkey,\"$server\")
$remotekey=$remote.OpenSubKey($pathkey,$true)
$remotekey.setvalue($key,$value)
[/code:1]
Message édité par: brutosaure, à: 20/05/10 16:38
Message édité par: brutosaure, à: 20/05/10 16:39<br><br>Message édité par: brutosaure, à: 20/05/10 16:40
Connexion ou Créer un compte pour participer à la conversation.
Temps de génération de la page : 0.037 secondes
- Vous êtes ici :
-
Accueil
-
forum
-
PowerShell
-
Entraide pour les débutants
- Accès distant au registre avec WMI