Wissen/X07_Technology_Registry.ps1

# ? TITEL Windows Registry
# ? DESCRIPTION Alles Rund um die Windows Registrierungsdatenbank und die Anbindung an PowerShell
# ? TAGS Registry PSProvider Software Product
# ? VERSION 2019.10.08

# ? Information bzgl. PSProvider und -Laufwerke
Get-PSProvider -PSProvider Registry
Get-PSDrive -PSProvider Registry

# ? Nativer Registry-Pfad verwenden
Get-ChildItem -Path Registry::HKEY_CURRENT_USER\Software\Microsoft\

# ? Ein Laufwerk erstellen für den Schlüssel HKEY_CURRENT_CONFIG
New-PSDrive -Name 'HKCC' -Root 'HKEY_CURRENT_CONFIG' -PSProvider Registry

# ? In den LAufwerken wechseln
Set-Location -Path HKCC:\System\CurrentControlSet
Set-Location -Path HKCU:\

# ? Schlüssel 'Abc' erstellen
New-Item -Path 'HKCU:\Software' -Name 'Abc' -ItemType 'Key' 

# ? Default-Wert für den Schlüssel 'Abc' setzen
Set-ItemProperty -Path 'HKCU:\Software\Abc' -Name '(default)' -Value 'Der Standard-Wert' -Type 'String'

# ? Eine NEUE Eigenschaft für den Schlüssel "Abc" erstellen
New-ItemProperty -Path 'HKCU:\Software\Abc' -Name 'Heute'  -Value (Get-Date -Format 'yyyy-MM-dd') -PropertyType 'String' -Force
New-ItemProperty -Path 'HKCU:\Software\Abc' -Name 'Anzahl' -Value 112          -PropertyType 'DWord'  -Force | Out-Null
# ! Mögliche Werte für PropertyType sind: String, ExpandString, Binary, DWord, MultiString, QWord, Unknown

# ? Eine VORHANDENE Eigenschaft ändern
Set-ItemProperty -Path 'HKCU:\Software\Abc' -Name 'Anzahl' -Value 113 -Type 'QWord' 

# ? Den Schlüssel 'Abc' lesen
Get-Item -Path 'HKCU:\Software\Abc'

# ? Den Schlüssel 'Abc' finden
Get-ChildItem -Path 'HKCU:\SOFTWARE' | Where-Object 'PSChildName' -eq 'abc'

# ? Den Default-Wert des Schlüssels 'Abc' lesen:
Get-ItemPropertyValue -Path 'HKCU:\Software\Abc' -Name '(default)'

# ? Den Wert von Heute des Schlüssels 'Abc' lesen:
Get-ItemProperty -Path 'HKCU:\Software\Abc' -Name 'Heute'
Get-ItemProperty -Path 'HKCU:\Software\Abc' | Select-Object -ExpandProperty 'Heute'
Get-ItemPropertyValue -Path 'HKCU:\Software\Abc' -Name 'Heute'

# ? Überprüfen ob der Schlüssel 'Abc' exzisiert
Test-Path -Path 'HKCU:\Software\Abc'

# ? Die Eigenschaft 'Heute' löschen:
Remove-ItemProperty -Path 'HKCU:\Software\Abc' -Name 'Heute'

# ? Den Default-Wert des Schlüssels 'Abc' leeren:
Set-ItemProperty -Path 'HKCU:\Software\Abc' -Name '(default)' -Value $null

# ? Den Schlüssel 'Abc' mit allen Eigenschaften und Unterschlüssel löschen
Remove-Item -Path 'HKCU:\Software\Abc' -Recurse -Force

# ? REZEPT: Installierte Software auflisten
$uninstallPath = 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*', `
                 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*', `
                 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*', `
                 'HKCU:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
$uninstallPath | Get-ItemProperty  |
  Where-Object -Property DisplayName | 
  Select-Object -Property DisplayName, DisplayVersion, Publisher, UninstallString