Question Accès distant au registre avec WMI

Plus d'informations
il y a 15 ans 10 mois #6880 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.

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

Plus d'informations
il y a 15 ans 10 mois #6924 par brutosaure
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

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

Plus d'informations
il y a 15 ans 10 mois #6925 par brutosaure
Ici une exemple de modification de key
[code:1]
$server=ton_server
$hkey=currentuser
$pathkey=\&quot;software\microsoft\windows\currentversion\internet settings\&quot;
$key=\&quot;ProxyEnable\&quot;
$value=\&quot;1\&quot;
$remote=[microsoft.win32.registrykey]::openremotebasekey($hkey,\&quot;$server\&quot;)
$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
Propulsé par Kunena