Inheritance: Disco.Services.Interop.ActiveDirectory.ADManagedGroup
        public static bool TryGetManagedGroup(DeviceBatch DeviceBatch, out DeviceBatchDevicesManagedGroup ManagedGroup)
        {
            ADManagedGroup managedGroup;
            string key = GetKey(DeviceBatch);

            if (ActiveDirectory.Context.ManagedGroups.TryGetValue(key, out managedGroup))
            {
                ManagedGroup = (DeviceBatchDevicesManagedGroup)managedGroup;
                return true;
            }
            else
            {
                ManagedGroup = null;
                return false;
            }
        }
        public static DeviceBatchDevicesManagedGroup Initialize(DeviceBatch DeviceBatch)
        {
            if (DeviceBatch.Id > 0)
            {
                var key = GetKey(DeviceBatch);

                if (!string.IsNullOrEmpty(DeviceBatch.DevicesLinkedGroup))
                {
                    var config = ADManagedGroup.ConfigurationFromJson(DeviceBatch.DevicesLinkedGroup);

                    if (config != null && !string.IsNullOrWhiteSpace(config.GroupId))
                    {
                        var group = new DeviceBatchDevicesManagedGroup(
                            key,
                            config,
                            DeviceBatch);

                        // Add to AD Context
                        ActiveDirectory.Context.ManagedGroups.AddOrUpdate(group);

                        return group;
                    }
                }

                // Remove from AD Context
                ActiveDirectory.Context.ManagedGroups.Remove(key);
            }

            return null;
        }