删除一个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 批量导入、删除帐号的更多相关文章

  1. 跟我学SharePoint 2013视频培训课程——删除恢复、文档离线工作(11)

    课程简介 第11天,怎样在SharePoint 2013中删除.恢复文档.文档离线工作. 视频 SharePoint 2013 交流群 41032413

  2. mssql删除数据库、删除帐号错误解决方法

    1. 删除数据库或者恢复数据库时,一定要先将数据库离线,在执行删除.恢复操作. SQL代码如下: /*使数据库离线*/ ALTER DATABASE [数据库名] SET OFFLINE WITH R ...

  3. mysql批量导入删除

    批量导入 <insert id="extractOrderBaseHis">INSERT INTO `odr_order_base_his`(`order_base_i ...

  4. 原!mysql存储过程 批量导入数据

    mysql需要导入某前缀例如12345为前缀的,后缀扩展2位 即00-99. 利用存储过程插入数据. DROP PROCEDURE IF EXISTS insert_popsms_code;DELIM ...

  5. 微软在线 VSTS/TFS 使用简介,如何删除项目,帐号,获取git地址等

    名称:微软 VSTS 全称: Visual Studio Team Services 地址:https://www.visualstudio.com/zh-hans/ 说明:注册就可以了使用了(如何使 ...

  6. 两个 github 账号混用,一个帐号提交错误

    问题是这样,之前有一个github帐号,因为注册邮箱的原因,不打算继续使用了,换了一个新的邮箱注册了一个新的邮箱帐号.新账号提交 就会出现下图的问题,但是原来帐号的库还是能正常提交.   方法1:添加 ...

  7. zabbix 同步ldap帐号脚本

    1.界面配置ldap验证(略) 2.mysql导入ldap帐号信息 #!/usr/bin/env python# -*- coding:utf-8 -*- import pymysqlimport c ...

  8. 迁移TFS,批量将文档导入SharePoint 2013 文档库

    一.需求分析 公司需要将存在于旧系统(TFS)所有的文档迁移至新系统(SharePoint 2013).现已经将50G以上的文档拷贝到SharePoint 2013 Server上.这些文档是一些不规 ...

  9. shell脚本,批量创建10个系统帐号并设置密码为随机8位字符串。

    [root@localhost wyb]# cat user10.sh #!/bin/bash #批量创建10个系统帐号wangyb01-wangyb10并设置密码(密码为随机8位字符串). > ...

随机推荐

  1. Redis命令总结 (转)

    Redis命令总结   连接操作相关的命令 quit:关闭连接(connection) auth:简单密码认证 持久化 save:将数据同步保存到磁盘 bgsave:将数据异步保存到磁盘 lastsa ...

  2. JavaScript 利用 async await 实现 sleep 效果

    const sleep = (timeountMS) => new Promise((resolve) => { setTimeout(resolve, timeountMS); }); ...

  3. 如何使用chrome浏览器进行js调试找出元素绑定的点击事件

    大家有没有遇到这样的一个问题,我们在分析一些大型电子商务平台的Web前端脚本时,想找到一个元素绑定的点击事件,并不是那么容易,因为有些前端脚本封装的比较隐蔽,甚至有些加密脚本,用传统的查找元素ID.或 ...

  4. WPF 矩形框8个控制点伸缩及拖拽

    最近在研发图片控件矩形框8个控制点进行控制边框的大小.位置等信息,之前查阅了相关的信息,比如别人整合的类:ControlResizer 这个类虽然是好,但是很大程度上是有限制,换句话说,它需要你二次更 ...

  5. python之requests

    发送请求 导入 Requests 模块: >>> import requests >>> r = requests.get('https://xxxxxxx.jso ...

  6. C_数据结构_数组

    //数组 # include <stdio.h> # include <malloc.h> //包含了 malloc 函数 # include <stdlib.h> ...

  7. Linux内核分析作业 NO.7

    可执行程序的装载 于佳心  原创作品转载请注明出处  <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 实 ...

  8. Linux第五周学习总结

    作者:黎静 一.知识点总结 (一)给MenuOS增加time和time-asm命令 1.更新menu代码到最新版 2.test.c中main函数里,增加MenuConfig() 3.增加对应的两个函数 ...

  9. Practise 5.2测试与封装(黑白盒

    本次测试与封装(黑白盒). 结伴队友:叶子鹏,他的博客地址:http://www.cnblogs.com/kazehanaai/ 由于我们的程序从一开始就一起弄的,所以测试的话不好换伙伴,所以我的伙伴 ...

  10. shell脚本第一课

    shell脚本的文件名一般是以.sh结尾,也可以以其他格式如.txt,甚至不加后缀. 脚本的第一行的#!/bin/bash表示指定脚本执行时的解析器. #!/bin/bash #文件名:test.sh ...