PowerShell/Registre

Aller à la navigation Aller à la recherche

PowerShell et le registre.

Généralité

Les différentes entrées pour le registre sont :

  • HKEY_CLASSES_ROOT
  • HKEY_CURRENT_USER
  • HKEY_LOCAL_MACHINE
  • HKEY_USERS
  • HKEY_CURRENT_CONFIG

Liste d'éléments concernant les utilisateurs sur un serveur RDS

$utilisateurListe = Get-ChildItem -Path Registry::HKEY_USERS\ | Where-Object {$_.Name -match '^HKEY_USERS\\S-1-5-21-[\d\-]+$'}
$liste = $null

foreach ($utilisateur in $utilisateurListe) {
    $chemin = Join-Path $utilisateur.PSPath "Software\FSLogix\Profiles\Session"
    $element = Get-ItemProperty -Path $chemin 
    Write-Host $utilisateur, $element.ProfilePath, $element.LocalProfilePath
    }

Création de plusieurs clés

$racine = "S-1-5-21-1234567890-123456789-123456789-"
$liste = Get-ChildItem -Path Registry::HKEY_USERS\ | Where-Object {$_.Name -match "$racine\d{4}$"}
foreach ($compte in $liste) {
    $branche = "Registry::\$compte\Volatile Environment\"
    ## Affichage de la valeur de la clé "USERNAME"
    (Get-ItemProperty -Path $branche -Name USERNAME).username
    New-ItemProperty -Path $branche -Name "test"             -PropertyType String -Value "Alphorm"
    New-ItemProperty -Path $branche -Name "HomepageLocation" -PropertyType String -Value "http://phpage.fr"
}

Voir aussi

  •