SharePoint 2013 批量导入、删除帐号
2014-03-31 16:43
246 查看
删除一个group里所有的帐号:
批量导入帐号:
帐号放到一个csv文件里,如下图:
执行步骤:
1. 运行上面的ps1脚本,输入log的path:
2. 输入A:
3. 输入site url和group id:
4. 输入帐号列表的csv文件:
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文件:
相关文章推荐
- 迁移TFS,批量将文档导入SharePoint 2013 文档库
- 迁移TFS,批量将文档导入SharePoint 2013 文档库
- 迁移TFS,批量将文档导入SharePoint 2013 文档库
- SharePoint 2013 删除母版页报错“This file may not be moved, deleted, renamed, or otherwise edited”
- 在Sharepoint中批量删除大量条目
- [导入]Asp.Net 文件操作基类(读取,删除,批量拷贝,删除,写入,获取文件夹大小,文件属性,遍历目录)(二)
- 跟我学SharePoint 2013视频培训课程——删除恢复、文档离线工作(11)
- 利用CSVDE和DSADD实现AD帐号批量导入导出
- 批量修改sharepoint 2013站点里区域设置
- 利用CSVDE和DSADD实现AD帐号批量导入导出
- windows 2003 帐号迁移 批量导入用户
- 活动目录大批量用户快速导入及误删除快速恢复
- shell批量导入mysql数据库,批量删除数据库
- 在 SharePoint 2013 中还原已删除的网站集
- 跟我学SharePoint 2013视频培训课程——删除恢复、文档离线工作(11)
- sharepoint 中批量导入导出
- 如何同时修改SharePoint帐号和AD帐号的密码 - 批量修改SharePoint Managed Account
- SharePoint 2013 可视化工作流设计图解---如何删除邮件错误。
- sharepoint 批量删除列表中的item
- 活动目录大批量用户快速导入及误删除快速恢复