SharePoint 2013 批量导入、删除帐号
删除一个group里所有的帐号:
cls
###########################
# "Enter the site URL here"
$SITEURL = "http://xxx/IT" # "Name of Site group from which users have to be removed"
$SITEGROUP = "Portal Information Technology Visitors" ########################### $site = new-object Microsoft.SharePoint.SPSite ( $SITEURL )
$web = $site.OpenWeb()
"Web is : " + $web.Title $oSiteGroup = $web.SiteGroups[$SITEGROUP]; "Site Group is :" + $oSiteGroup.Name
$oUsers = $oSiteGroup.Users foreach ($oUser in $oUsers)
{
"Removing user : " + $oUser.Name
$oSiteGroup.RemoveUser($oUser)
} ######################################################################################################
批量导入帐号:
###########################################################################################
#
# Title: Add-SPUser_Group.ps1
#
# Description: Adds a group of users to a SharePoint group via an answer file
#
# URL: http://techchucker.wordpress.com/2013/09/17/addbulkspusergroups/
#
# Author: Matt Anderson
# Created: 9-13-2013
#
########################################################################################## #Region Action Function
#Action taken via user input based on menu option chosen
Function Action ($result)
{
if ($result -eq "A")
{
AnswerCreate
}
if ($result -eq "B")
{ }
if ($result -eq "?")
{
clear
#Opens Default Internet browser and navigates to the below site that holds the instructions for this program
Start-Process -FilePath "http://techchucker.wordpress.com/2013/09/17/addbulkspusergroups/"
}
}
#endRegion #Region PressKey Function #User must enter any key to continue
Function PressKey
{
Write-Host "Press any key to continue..." -ForegroundColor Black -BackgroundColor White $x = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp,AllowCtrlC") return clear
}
#endRegion #Region WebInput Function
#Function to request web input from user
Function WebInput
{
$inpWeb = Read-Host "Enter the URL of the site to add users to a group" return $inpWeb
}
#endRegion #Region GroupInput Function
#Function to request SharePoint Group input from user
Function GroupInput
{
$inpGroup = Read-Host "Enter the SharePoint Group ID to add users to" return $inpGroup
}
#endRegion #Region AnswerCeate Function #Function to take answer file and add multiple users to SharePoint Group
Function AnswerCreate
{
clear #Imports user inputted answer file
$userList = Import-Csv ($answerFile = Read-Host "Enter path to Answer File (e.g. c:\filename.csv)")
$web = WebInput
$group = GroupInput Write-Output $userList
PressKey #Iterates through each record storing variables and executing user add
ForEach ($user in $userList)
{
$validateUser = $null
$LANID = $user."LANID" $validateUser = Get-SPUser -Identity $LANID -Web $web -ErrorAction SilentlyContinue #This will throw an error if the user does not exist if($validateUser -eq $null)
{
Write-Host $LANID "does not exist"
New-SPUser -UserAlias $LANID -Web $web -group $group
Write-Host $LANID "created and added to " $group
}
else
{
#Adds user/s to the SharePoint group
Set-SPUser -Identity $LANID -Web $web -Group $group
Write-Host $LANID "has been added to "$group
}
}
}
#endRegion #Region Menu Function #Function to display the menu for the program
Function Menu
{
Write-Host "Add Users to SP Groups in Bulk`n`n" -ForegroundColor Black -BackgroundColor White
Write-Host "Choose the action you would like to perform shown below.`n`n" Write-Host " A - Add users in bulk using Answer File`n"
Write-Host " ? - Program Help`n"
Write-Host " Exit Exits this program`n`n"
}
#endRegion #Region Program Actions
$ErrorActionPreference="SilentlyContinue"
Stop-Transcript | out-null
$ErrorActionPreference = "Continue" $logPath = Read-Host "Enter log path (c:\Logs)"
$date = Get-Date -UFormat %y%m%d.%H.%M.%S
$logFile = "\" + $date + "_AddUserGroup.txt" Start-Transcript -path $logPath$logFile -append do
{
clear
Menu
$result = Read-Host "Enter your selection"
if($result -ne "exit")
{
Action $result
#Write-Host "Would you like to return to the main menu?`n`n"
#$confirm = Confirm ($inp = Read-Host "Enter Y or N")
$confirm = $True
}
else
{
$confirm = $false
}
}
while($confirm -eq $True) Stop-Transcript
#endRegion
帐号放到一个csv文件里,如下图:

执行步骤:
1. 运行上面的ps1脚本,输入log的path:

2. 输入A:

3. 输入site url和group id:

4. 输入帐号列表的csv文件:

SharePoint 2013 批量导入、删除帐号的更多相关文章
- 跟我学SharePoint 2013视频培训课程——删除恢复、文档离线工作(11)
课程简介 第11天,怎样在SharePoint 2013中删除.恢复文档.文档离线工作. 视频 SharePoint 2013 交流群 41032413
- mssql删除数据库、删除帐号错误解决方法
1. 删除数据库或者恢复数据库时,一定要先将数据库离线,在执行删除.恢复操作. SQL代码如下: /*使数据库离线*/ ALTER DATABASE [数据库名] SET OFFLINE WITH R ...
- mysql批量导入删除
批量导入 <insert id="extractOrderBaseHis">INSERT INTO `odr_order_base_his`(`order_base_i ...
- 原!mysql存储过程 批量导入数据
mysql需要导入某前缀例如12345为前缀的,后缀扩展2位 即00-99. 利用存储过程插入数据. DROP PROCEDURE IF EXISTS insert_popsms_code;DELIM ...
- 微软在线 VSTS/TFS 使用简介,如何删除项目,帐号,获取git地址等
名称:微软 VSTS 全称: Visual Studio Team Services 地址:https://www.visualstudio.com/zh-hans/ 说明:注册就可以了使用了(如何使 ...
- 两个 github 账号混用,一个帐号提交错误
问题是这样,之前有一个github帐号,因为注册邮箱的原因,不打算继续使用了,换了一个新的邮箱注册了一个新的邮箱帐号.新账号提交 就会出现下图的问题,但是原来帐号的库还是能正常提交. 方法1:添加 ...
- zabbix 同步ldap帐号脚本
1.界面配置ldap验证(略) 2.mysql导入ldap帐号信息 #!/usr/bin/env python# -*- coding:utf-8 -*- import pymysqlimport c ...
- 迁移TFS,批量将文档导入SharePoint 2013 文档库
一.需求分析 公司需要将存在于旧系统(TFS)所有的文档迁移至新系统(SharePoint 2013).现已经将50G以上的文档拷贝到SharePoint 2013 Server上.这些文档是一些不规 ...
- shell脚本,批量创建10个系统帐号并设置密码为随机8位字符串。
[root@localhost wyb]# cat user10.sh #!/bin/bash #批量创建10个系统帐号wangyb01-wangyb10并设置密码(密码为随机8位字符串). > ...
随机推荐
- WPF模拟探照灯文字
原文:WPF模拟探照灯文字 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/yangyisen0713/article/details/1835936 ...
- 51Nod 1668 非010串
这是昨天上课ChesterKing dalao讲线代时的例题 当时看到这道题就觉得很水,记录一下后面两位的情况然后讨论一下转移即可 由于之前刚好在做矩阵题,所以常规的矩阵快速幂优化也很简单 好我们开始 ...
- MongoDB的导入导出
一:MongoDB的导出功能 mongodb提供了导入和导出的功能,分别是MongoDB下载目录下的mongoexport.exe和mongoimport.exe文件 ,具体的导出命令格式如下: mo ...
- R实战 第十篇:列联表和频数表
列联表是观测数据按两个或更多属性(定性变量)分类时所列出的频数分布表,它是由两个以上的变量进行交叉分类的频数分布表.交互分类的目的是将两变量分组,然后比较各组的分布状况,以寻找变量间的关系. 按两个变 ...
- (10)学习笔记 ) ASP.NET CORE微服务 Micro-Service ---- Ocelot+Identity Server
用 JWT 机制实现验证的原理如下图: 认证服务器负责颁发 Token(相当于 JWT 值)和校验 Token 的合法性. 一. 相关概念 API 资源(API Resource):微博服务器接口. ...
- linux-阿里云仓库搭建-搭建本地仓库-yum
以上是同步元数据信息 安装完成———————————————————————————— 本地库的搭建 是建立在rpm之上的封装 可用的包 把仓库信息链接到本地 使用中文显示, 我们平时用的是oracl ...
- Note: SE Class's Individual Project
虽然第一个Project还有点小问题需要修改,但是大体已经差不多了,先把blog记在这里,算是开博第一篇吧! 1.项目预计的用时 本来看到这个题的时候想的并不多,但是看了老师的要求才觉得如此麻烦ORZ ...
- 猫咪记单词Beta版使用说明
猫咪记单词Beta版使用说明 一.项目背景 英语四级考试.六级考试.托福.雅思等英语方面的考试是现在大学生必须面对的问题.同时因为学生对手机的使用越来越频繁,而且仅仅通过书本背诵单词又比较无聊坚持的时 ...
- action中session的存取
存 ActionContext.getContext().getSession().put("teacherlist", teacherlist); 取 teacherlist=( ...
- 用软件工程分析开源项目octave的移植
在本科的时候学习了软件工程,报考了信息系统项目管理师的考试,,虽然没有过,但是其实还是学了一些相关项目管理方面的知识,,9大管理,,当年应该能背出来,,, 1 项目整体管理 2 项目范围管理 3 项目 ...