Help with Powershell command

Hello Guys
i hope someone can help me as iam very new with Powershell.
I have the following script which is working fine so far:

function Test-RegistryValue {

param (

 [parameter(Mandatory=$true)]
 [ValidateNotNullOrEmpty()]$Path,

[parameter(Mandatory=$true)]
 [ValidateNotNullOrEmpty()]$Value
)

try {
    Get-ItemProperty -Path $Path -ErrorAction Stop | Select-Object -ExpandProperty $Value -ErrorAction Stop | Out-Null
    return $true
 }

catch {
    return $false
}

}

Test-RegistryValue -Path “HKCU:\SOFTWARE\CompanyName” -Value “LanguageListPopulated”

$LanguageList = Get-WinUserLanguageList
$LanguageList.Add(“de-ch”)
$LanguageList.Add(“fr-fr”)
$LanguageList.Add(“it-it”)
$LanguageList.Add(“es-es”)
Set-WinUserLanguageList $LanguageList -force

New-Item -Path “HKCU:\SOFTWARE” -Name “CompanyName” -Force
New-ItemProperty -Path “HKCU:\SOFTWARE\CompanyName” -Name “LanguageListPopulated” -Value “1” -PropertyType String -Force

Now i would like to add the function to check if the Regkey "HKCU:\SOFTWARE\CompanyName -Value “LanguageListPopulated” already exist and if yes the the script should stop (exit) otherwise Language List will be populated. at the moment this script runs always thru even the language where already added…

can someone help me with this?
thanks

KayaDee,
Welcome to the forum. :wave:t4:

When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org <---- Click :point_up_2:t4: :wink:

Why would you like to re-invent the wheel again? For the vast majority of the cases you’re not the very first one with a given task. Please use your prefered internet search engine to search for examples you could adapt to your particular needs or simply use as inspiration for your own code.
Like this:
https://www.google.com/search?q=powershell+test+registry+value