protected void EnablePrivilege(Privilege privilege) { //throw an exception if the specified prililege is not held by the client if (!privileges.Any(p => p.Privilege == privilege)) { throw new System.Security.AccessControl.PrivilegeNotHeldException(privilege.ToString()); } //if the privilege is disabled if (privileges.Single(p => p.Privilege == privilege).PrivilegeState == PrivilegeState.Disabled) { WriteDebug(string.Format("The privilege {0} is disabled...", privilege)); //activate it privControl.EnablePrivilege(privilege); WriteDebug(string.Format("..enabled")); //remember the privilege so that we can automatically disable it after the cmdlet finished processing enabledPrivileges.Add(privilege.ToString()); privileges = privControl.GetPrivileges(); } }
protected override void ProcessRecord() { var privControl = new PrivilegeControl(); this.WriteObject(privControl.GetPrivileges(), true); }