批量导入导出站点权限site permissions
批量导入站点权限
cls
$Web = Get-SPWeb "http://16.178.115.14:91/"
Get-Content c:\export\account.txt | ForEach-Object {
Write-Host $_ $account = $web.EnsureUser($_.Split(',')[0])
$role = $web.RoleDefinitions[$_.Split(',')[1]] $assignment = New-Object Microsoft.SharePoint.SPRoleAssignment($account)
$assignment.RoleDefinitionBindings.Add($role) $web.RoleAssignments.Add($assignment)
}
-----------
mitpalm4\xuting,Full Control
mitpalm4\lily,Read
批量导出站点权限
cls
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) { Add-PSSnapin "Microsoft.SharePoint.PowerShell" } $properties=@{SiteUrl='';SiteTitle='';ListTitle='';ObjectType='';ObjectUrl='';ParentGroup='';GroupOwner='';MemberType='';MemberName='';MemberLoginName='';JobTitle='';Department='';RoleDefinitionBindings='';}; $Permissions=@(); $UserInfoList=""; $RootWeb=""; $SiteCollectionUrl = Read-Host "Enter a Site Collection Url"; Get-SPSite $SiteCollectionUrl|Get-SPWeb -limit ALL|%{ $web = $_; #Root Web of the Site Collection if($web.IsRootWeb -eq $True){ $RootSiteTitle = $web.Title; $RootWeb = $web; $UserInfoList = $RootWeb.GetList([string]::concat($web.Url,"/_catalogs/users")); } $siteUrl = $web.Url; $siteRelativeUrl = $web.ServerRelativeUrl; Write-Host $siteUrl -Foregroundcolor "Red"; $siteTitle = $web.Title; #Get Site Level Permissions if it's unique if($web.HasUniqueRoleAssignments -eq $True){ $web.RoleAssignments|%{ $RoleDefinitionBindings=@(); $_.RoleDefinitionBindings|%{ $RoleDefinitionBindings += $_.Name; } $MemberName = $_.Member.Name; $MemberLoginName = $_.Member.LoginName; $MemberType = $_.Member.GetType().Name; $GroupOwner = $_.Member.Owner.Name; if($MemberType -eq "SPGroup"){ $JobTitle="NA"; $Department="NA"; $permission = New-Object -TypeName PSObject -Property $properties; $permission.SiteUrl =$siteUrl; $permission.SiteTitle = $siteTitle; $permission.ListTitle = "NA"; $permission.ObjectType = "Site"; $permission.ObjectUrl = $siteRelativeUrl; $permission.MemberType = $MemberType; $permission.ParentGroup = $MemberName; $permission.GroupOwner = $GroupOwner; $permission.MemberName = $MemberName; $permission.MemberLoginName = $MemberLoginName; $permission.JobTitle = $JobTitle; $permission.Department = $Department; $permission.RoleDefinitionBindings = $RoleDefinitionBindings -join ","; $Permissions +=$permission; #Expand Groups $web.Groups[$MemberName].Users|%{ $JobTitle="NA"; $Department="NA"; try{ $userinfo = $UserInfoList.GetItemById($_.ID); $JobTitle=$userinfo["JobTitle"]; $Department=$userinfo["Department"]; } catch{ } $permission = New-Object -TypeName PSObject -Property $properties; $permission.SiteUrl =$siteUrl; $permission.SiteTitle = $siteTitle; $permission.ListTitle = "NA"; $permission.ObjectType = "Site"; $permission.ObjectUrl = $siteRelativeUrl; $permission.MemberType = "SPGroupMember"; $permission.ParentGroup = $MemberName; $permission.GroupOwner = $GroupOwner; $permission.MemberName = $_.DisplayName; $permission.MemberLoginName = $_.UserLogin; $permission.JobTitle = $JobTitle; $permission.Department = $Department; $permission.RoleDefinitionBindings = $RoleDefinitionBindings -join ","; $Permissions +=$permission; } } elseif($MemberType -eq "SPUser"){ $JobTitle="NA"; $Department="NA"; try{ $userinfo = $UserInfoList.GetItemById($_.ID); $JobTitle=$userinfo["JobTitle"]; $Department=$userinfo["Department"]; } catch{ } $permission = New-Object -TypeName PSObject -Property $properties; $permission.SiteUrl =$siteUrl; $permission.SiteTitle = $siteTitle; $permission.ListTitle = "NA"; $permission.ObjectType = "Site"; $permission.MemberType = $MemberType; $permission.ObjectUrl = $siteRelativeUrl; $permission.ParentGroup = "NA"; $permission.GroupOwner = "NA"; $permission.MemberName = $MemberName; $permission.MemberLoginName = $MemberLoginName; $permission.JobTitle = $JobTitle; $permission.Department = $Department; $permission.RoleDefinitionBindings = $RoleDefinitionBindings -join ","; $Permissions +=$permission; } } } #Get all Uniquely secured objects $uniqueObjects = $web.GetWebsAndListsWithUniquePermissions(); #Get uniquely secured Lists pertaining to the current site $uniqueObjects|?{$_.WebId -eq $web.Id -and $_.Type -eq "List"}|%{ $listUrl = ($_.Url); $list = $web.GetList($listUrl); #Exclude internal system lists and check if it has unique permissions if($list.Hidden -ne $True){ Write-Host $list.Title -Foregroundcolor "Yellow"; $listTitle = $list.Title; #Check List Permissions if($list.HasUniqueRoleAssignments -eq $True){ $list.RoleAssignments|%{ $RoleDefinitionBindings=""; $_.RoleDefinitionBindings|%{ $RoleDefinitionBindings += $_.Name; } $MemberName = $_.Member.Name; $MemberLoginName = $_.Member.LoginName; $MemberType = $_.Member.GetType().Name; $JobTitle="NA"; $Department="NA"; if($MemberType -eq "SPUser"){ try{ $userinfo = $UserInfoList.GetItemById($_.ID); $JobTitle=$userinfo["JobTitle"]; $Department=$userinfo["Department"]; } catch{ } } $permission = New-Object -TypeName PSObject -Property $properties; $permission.SiteUrl =$siteUrl; $permission.SiteTitle = $siteTitle; $permission.ListTitle = $listTitle; $permission.ObjectType = $list.BaseType.ToString(); $permission.ObjectUrl = $listUrl; $permission.ParentGroup = "NA"; $permission.GroupOwner = "NA"; $permission.MemberType=$MemberType; $permission.MemberName = $MemberName; $permission.MemberLoginName = $MemberLoginName; $permission.JobTitle = $JobTitle; $permission.Department = $Department; $permission.RoleDefinitionBindings = $RoleDefinitionBindings -join ","; $Permissions +=$permission; } } if($list.BaseType -eq "DocumentLibrary"){ #Check All Folders $list.Folders|%{ $folderUrl = $_.Url; if($_.HasUniqueRoleAssignments -eq $True){ $_.RoleAssignments|%{ $RoleDefinitionBindings=""; #Get Permission Level against the Permission $_.RoleDefinitionBindings|%{ $RoleDefinitionBindings += $_.Name; } $MemberName = $_.Member.Name; $MemberLoginName = $_.Member.LoginName; $MemberType = $_.Member.GetType().Name; $JobTitle="NA"; $Department="NA"; if($MemberType -eq "SPUser"){ try{ $userinfo = $UserInfoList.GetItemById($_.ID); $JobTitle=$userinfo["JobTitle"]; $Department=$userinfo["Department"]; } catch{ } } $permission = New-Object -TypeName PSObject -Property $properties; $permission.SiteUrl =$siteUrl; $permission.SiteTitle = $siteTitle; $permission.ListTitle = $listTitle; $permission.ObjectType = $list.BaseType.ToString(); $permission.ObjectUrl = $folderUrl; $permission.MemberType = $MemberType; $permission.ParentGroup = "NA"; $permission.GroupOwner = "NA"; $permission.MemberName = $MemberName; $permission.MemberLoginName = $MemberLoginName; $permission.JobTitle = $JobTitle; $permission.Department = $Department; $permission.RoleDefinitionBindings = $RoleDefinitionBindings -join ","; $Permissions +=$permission; } } } #Check All Items $list.Items|%{ $fileUrl = $_.File.Url; $file=$_.File; if($_.HasUniqueRoleAssignments -eq $True){ $_.RoleAssignments|%{ $RoleDefinitionBindings=""; $_.RoleDefinitionBindings|%{ $RoleDefinitionBindings += $_.Name; } $MemberName = $_.Member.Name; $MemberLoginName = $_.Member.LoginName; $MemberType = $_.Member.GetType().Name; $JobTitle="NA"; $Department="NA"; if($MemberType -eq "SPUser"){ try{ $userinfo = $UserInfoList.GetItemById($_.ID); $JobTitle=$userinfo["JobTitle"]; $Department=$userinfo["Department"]; } catch{ } } $permission = New-Object -TypeName PSObject -Property $properties; $permission.SiteUrl =$siteUrl; $permission.SiteTitle = $siteTitle; $permission.ListTitle = $listTitle; $permission.ObjectType = $file.GetType().Name; $permission.ObjectUrl = $fileUrl; $permission.MemberType=$MemberType; $permission.MemberName = $MemberName; $permission.MemberLoginName = $MemberLoginName; $permission.JobTitle = $JobTitle; $permission.Department = $Department; $permission.RoleDefinitionBindings = $RoleDefinitionBindings -join ","; $Permissions +=$permission; } } } } } } if($_.IsRootWeb -ne $True){ $_.Dispose(); } } #Dispose root web $RootWeb.Dispose(); $Permissions|select SiteUrl,SiteTitle,ObjectType,ObjectUrl,ListTitle,MemberName,MemberLoginName,MemberType,JobTitle,Department,ParentGroup,GroupOwner,RoleDefinitionBindings|Export-CSV ("c:\"+$RootSiteTitle+"-Permissions.csv") -NoTypeInformation;
批量导入导出站点权限site permissions的更多相关文章
- 报表开发之批量导入导出excel
在日常使用报表过程中,会有这样一种情况,你将Excel表分发给各个员工,员工填完后,统一整理成多个Excel,你需要将这些数据,用报表的填报功能,提交录入到数据库中,这样一来可避免到服务器机房录数据的 ...
- PowerShell 批量导入/导出Active Directory
PowerShell 批量导入/导出Active Directory 近期由于公司要求,须要导入20个供应商.20个客户到AD域中,刚開始手动添�了2个供应商,2个客户.可是感觉费时费 ...
- [转]Office导入导出组件权限配置汇总
原文地址:Office导入导出组件权限配置汇总 具体配置方法如下: 1:在服务器上安装office的Excel软件. 2:在"开始"->"运行"中输入 ...
- SQL Server中bcp命令的用法以及数据批量导入导出
原文:SQL Server中bcp命令的用法以及数据批量导入导出 1.bcp命令参数解析 bcp命令有许多参数,下面给出bcp命令参数的简要解析 用法: bcp {dbtable | query} { ...
- 如何在IIS7或IIS7.5中导入导出站点及应用程序池.
为实现负载平衡,我们可能会使用多个WEB服务器,也就会需要给多个IIS配置同样的站点和应用程序池.那么我们需要一个一个的重新建吗?当然不用,我们只需要一些简单的命令就可以在IIS7(Windows S ...
- 如何在IIS7或IIS7.5中导入导出站点及应用程序池. -摘自网络
为实现负载平衡,我们可能会使用多个WEB服务器,也就会需要给多个IIS配置同样的站点和应用程序池.那么我们需要一个一个的重新建吗?当然不用,我们只需要一些简单的命令就可以在IIS7(Windows S ...
- 用poi框架进行批量导入导出实例
Apache POI是Apache软件基金会的开放源码函式库,POI提供API给Java程式对Microsoft Office格式档案读和写的功能.我们这里使用poi对数据库中的数据进行批量导出,以及 ...
- asp.net mvc4 easyui datagrid 增删改查分页 导出 先上传后导入 NPOI批量导入 导出EXCEL
效果图 数据库代码 create database CardManage use CardManage create table CardManage ( ID ,) primary key, use ...
- java实现文件批量导入导出实例(兼容xls,xlsx)
1.介绍 java实现文件的导入导出数据库,目前在大部分系统中是比较常见的功能了,今天写个小demo来理解其原理,没接触过的同学也可以看看参考下. 目前我所接触过的导入导出技术主要有POI和iRepo ...
随机推荐
- Android恶意样本数据集汇总
硕士论文的研究方向为Android恶意应用分类,因此花了一点时间去搜集Android恶意样本.其中一部分来自过去论文的公开数据集,一部分来自社区或平台的样本.现做一个汇总,标明了样本或数据集的采集时间 ...
- React.js 开发参见问题 Q&A
文章中我整理了 React.js 开发过程中一些参见问题的解答汇总,供大家参考. 1. 一些课程资源 课程完整的思维导图请查考文章:React.js 入门与实战课程思维导图,我使用的思维导图软件是 M ...
- Openstack架构概念图-简单汇总
OpenStack是一个云平台管理的项目,它不是一个软件.这个项目由几个主要的组件组合起来完成一些具体的工作.想要了解openstack,第一步我们可以观察他的概念图: 针对上图的翻译+解释: 上图主 ...
- 手动编写的几个简单的puppet管理配置
puppet在自动化配置管理方面有很强大的优势,这里就不做过多介绍了,下面记录下几个简单的puppet管理配置: 一.首先在服务端和客户端安装puppet和facter 1)服务端 安装Puppet ...
- jsonrpc环境搭建和简单实例
一.环境准备 下载需要的jar包和js文件,下载地址:https://yunpan.cn/cxvbm9DhK9tDq 访问密码 6a50 二.新建一个web工程,jsonrpc-1.0.jar复制到 ...
- ACM注意事项
acm竞赛中不能使用一些屏幕控制和键盘读取的函数,如:getch(),geche(),gotoxy(),clrscr(),另外fflush(stdio)这个函数也不能使用,因为在有的编译 ...
- 《Linux内核分析》第八周
<Linux内核分析>第八周 PART ONE 知识点总结 一.进程切换的关键代码switch_to 1.进程调度与进程调度的时机 (1)进程分类: I/O型(执行块,频繁) CPU型(大 ...
- Android中Json数据读取与创建的方法
转自:http://www.jb51.net/article/70875.htm 首先介绍下JSON的定义,JSON是JavaScript Object Notation的缩写. 一种轻量级的数据交换 ...
- JAVA面对对象(三)——Super、static、final关键字
Super 使用super关键字可以直接调用父类中的构造方法.属性.普通方法 super调用父类构造方法的操作,与this调用构造方法一样,语句必须放在子类构造方法的首行 public class P ...
- Docker(十三)-Docker save and load镜像保存
持久化docker的镜像或容器的方法 Docker的镜像和容器可以有两种方式来导出 docker save #ID or #Name docker export #ID or #Name docker ...