PowerShell - 具有独特权限的新 SPWeb
我想使用 PowerShell 创建一个新的 SPWeb。 我的代码创建网站并将组添加到网站,但不添加用户“TestUser1”。 test\testuser1不属于TestGroup1并获得独立权限。
$web = New-spweb http://http:/mysharepointurl/site/web -Template "STS#0" -UniquePermissions
$user = $web.EnsureUser('test\testuser4')
$web.Users.AddUser($user, "Full") #Not working, Add a existing User
$newGroup = $web.SiteGroups["TestGroup6"] #Working, Add a existing Group
$web.Roles["Full"].AddGroup($newGroup)
I want to create a new SPWeb with PowerShell.
My code creates the site and add the group to the site but not the user "TestUser1".
The test\testuser1 belongs not to the TestGroup1 and get intepend permissions.
$web = New-spweb http://http:/mysharepointurl/site/web -Template "STS#0" -UniquePermissions
$user = $web.EnsureUser('test\testuser4')
$web.Users.AddUser($user, "Full") #Not working, Add a existing User
$newGroup = $web.SiteGroups["TestGroup6"] #Working, Add a existing Group
$web.Roles["Full"].AddGroup($newGroup)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否尝试过
$web.Users.Add
-或-$web.AllUsers.Add
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spusercollection.add.aspx
Have you tried
$web.Users.Add
-or-$web.AllUsers.Add
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spusercollection.add.aspx
您正在使用
New-SPWeb
,因此这意味着您需要将用户添加到SPWeb
。$web.SiteUsers
是网站集组http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.siteusers.aspx
您应该使用
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.users.aspx
You are using
New-SPWeb
, so that means you need to be adding users to theSPWeb
.$web.SiteUsers
is the site collection grouphttp://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.siteusers.aspx
You should use
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.users.aspx
我的工作解决方案:
感谢支持!
My working solution:
Thanks for the support!