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