Da es ziemlich kurz ist, könnte dies einen Anlass geben:
$registryPath = "HKCU:\Software\Test\" #reg key $Name = "setting" #reg value $value = "ABCDDD" #default value if does not exist IF(!(Test-Path $registryPath)) { #Key does not exist, create key and set default New-Item -Path $registryPath -Force | Out-Null New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType String -Force | Out-Null } ELSE { #Key exists, read existing value and trim $strValue = (Get-ItemProperty -Path $registryPath).($Name) $strNew = $strValue.SubString(0,3) New-ItemProperty -Path $registryPath -Name $name -Value $strNew -PropertyType String -Force | Out-Null }