Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
sharepoint 2010中未正确设置RequestToJoinLeaveEmailSetting_Sharepoint_Powershell_Sharepoint 2010 - Fatal编程技术网

sharepoint 2010中未正确设置RequestToJoinLeaveEmailSetting

sharepoint 2010中未正确设置RequestToJoinLeaveEmailSetting,sharepoint,powershell,sharepoint-2010,Sharepoint,Powershell,Sharepoint 2010,我正在使用对象模型更新组。使用PowerShell命令时,我在“RequestToJoinLeaveEmailSetting”字段中设置的值未显示。但是,当我通过对象模型获取它时,它会显示设置为“RequestToJoinLeaveEmailSetting”字段的新值 使用PowerShell命令,我可以更新此字段。但是,从对象模型中,我得到的值是从对象本身设置的,而不是由PowerShell设置的 怎么能同步呢?有什么帮助/想法吗 提前谢谢。 莫哈克 这是我的密码: SPSite Si

我正在使用对象模型更新组。使用PowerShell命令时,我在“RequestToJoinLeaveEmailSetting”字段中设置的值未显示。但是,当我通过对象模型获取它时,它会显示设置为“RequestToJoinLeaveEmailSetting”字段的新值

使用PowerShell命令,我可以更新此字段。但是,从对象模型中,我得到的值是从对象本身设置的,而不是由PowerShell设置的

怎么能同步呢?有什么帮助/想法吗

提前谢谢。 莫哈克

这是我的密码:

    SPSite Site = new SPSite(siteUrl);
    SPWeb spWeb = Site.OpenWeb();
    SPGroup spGroup = spWeb.SiteGroups[oldname];
    SPRoleCollection roles = spGroup.Roles;
    if (roles != null)
    {
    oldRoles = new ArrayList();
    foreach (SPRole role in roles)
    {
    oldRoles.Add(role.Name);
    }
    }
    // here we are comparing the old and new roles to be updated and separating out
    // which roles to be deleted and which is to be updated.
    foreach (string role in oldRoles)
    {
    if (newRoles.Contains(role))
    {
    updatedRoles.Add(role);
    }
    else
    {
    removeRoles.Add(role);
    }
    }
    foreach (string rolenames in newRoles)
    {
    if (!oldRoles.Contains(rolenames))
    {
    updatedRoles.Add(rolenames);
   }
   }
   if (removeRoles != null && removeRoles.Count > 0)
   {
   SPRoleAssignment roleAssignment = new SPRoleAssignment(spGroup);
   foreach (string str in removeRoles)
   {
   SPRoleDefinition role = spWeb.RoleDefinitions[str];
   //SPRoleAssignment roleAssignment = new SPRoleAssignment(spGroup);
   roleAssignment.RoleDefinitionBindings.Remove(role);
   spWeb.RoleAssignments.Remove(roleAssignment.Member);
   spWeb.Update();
   }
   spWeb.Update();
   }
   if (spGroup != null)
   {
   spGroup.Description = description;
   spGroup.Name = name;
   spGroup.OnlyAllowMembersViewMembership = viewprmsn;
   spGroup.AllowMembersEditMembership = edprmsn;
   spGroup.AllowRequestToJoinLeave = mbrrqst;
   spGroup.AutoAcceptRequestToJoinLeave = acptrqst;
   spGroup.RequestToJoinLeaveEmailSetting = emailid;               

   if (updatedRoles != null && updatedRoles.Count > 0)
   SPRoleAssignment roleAssignment = new SPRoleAssignment(spGroup);
   // SPRoleDefinition roleDefinition = spWeb.RoleDefinitions["Contribute"];
   foreach (string str in updatedRoles)
   {
   SPRoleDefinition roleDefinition = spWeb.RoleDefinitions[str];
   roleAssignment.RoleDefinitionBindings.Add(roleDefinition);
   }
   spWeb.RoleAssignments.Add(roleAssignment);
   }
   //spGroup.RequestToJoinLeaveEmailSetting = emailid;
   spGroup.Update();
   }
   spWeb.Update();
   }
   catch (Exception ex)
   {
   SPTlogger.Error("-------------------------ERROR-------------------------");
   SPTlogger.Error("Error in UpdateGroup():" + ex.Message);
   throw new Exception(ex.Message);
   }
   finally
   {
   SPTlogger.Debug("<-- : UpdateGroup()");
   }
   }

似乎您忘记了在更新组属性时使用应用更改

PS示例:

$web = Get-SPWeb $webUrl
$membersGroup = $web.AssociatedMemberGroup
$membersGroup.RequestToJoinLeaveEmailSetting = "admin@intranet.contoso.com"
$membersGroup.Update() #save group changes