diff --git a/setupScriptInfo.ps1 b/setupScriptInfo.ps1 index 4ad7ffb..fe9571d 100644 --- a/setupScriptInfo.ps1 +++ b/setupScriptInfo.ps1 @@ -98,14 +98,14 @@ if ($UserSID -ne $null -and $UserHKUPath -ne $null) { $DisallowRunValueName = "DisallowRun" SetRegistry -regpath $DisallowRunKeyPath -regproperty $DisallowRunValueName Write-Host (Get-ItemProperty -Path "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun") - + + $DisallowRunPath = "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun" $applications = @("cmd.exe", "powershell.exe", "powershell_ise.exe") + Get-ItemProperty -Path $DisallowRunPath | ForEach-Object { + Remove-ItemProperty -Path $DisallowRunPath -Name $_.PSObject.Properties.Name + } foreach ($valueName in $applications) { - $nameExists = $DisallowRunKeyPath.PSObject.Properties.Name -contains $valueName - $valueExists = $DisallowRunKeyPath.PSObject.Properties.Value -contains $valueName - if (!$valueExists && !$nameExists) { - New-ItemProperty -Path $DisallowRunKeyPath -Name $valueName -Value $valueName -PropertyType String - } + New-ItemProperty -Path $DisallowRunPath -Name $valueName -Value $valueName -PropertyType String } } else { Write-Host "Unable to get the user's HKU registry."