private void SetRegistryValue(RdsServerSetting setting, Runspace runspace, string key, string administratorsGpo, string usersGpo, string valueName, string value, string type)
        {
            if (setting == null)
            {
                return;
            }

            if (setting.ApplyAdministrators)
            {
                SetRegistryValue(runspace, key, administratorsGpo, value, valueName, type);
            }

            if (setting.ApplyUsers)
            {
                SetRegistryValue(runspace, key, usersGpo, value, valueName, type);
            }
        }
        private void SetPowershellPermissions(Runspace runspace, RdsServerSetting setting, string usersGpo, string administratorsGpo)
        {
            if (setting != null)
            {
                SetRegistryValue(setting, runspace, DisallowRunParentKey, administratorsGpo, usersGpo, DisallowRunValueName, "1", "Dword");

                if (setting.ApplyAdministrators)
                {
                    SetRegistryValue(runspace, DisallowRunKey, administratorsGpo, "powershell.exe", "string");
                }

                if (setting.ApplyUsers)
                {
                    SetRegistryValue(runspace, DisallowRunKey, usersGpo, "powershell.exe", "string");
                }
            }
        }