SharePoint發(fā)行版本有SharePoint2003、SharePoint2007、Sharepoint 2010、SharePoint2013和SharePoint2016。SharePoint提供了功能強(qiáng)大的團(tuán)隊協(xié)作環(huán)境,使得組織能夠在整個組織內(nèi)部實現(xiàn)整合、組織、查找和提供 SharePoint站點。 最近,生產(chǎn)環(huán)境上線,好多好多用戶組需要配置,一大批人要分別加到各種組,BA的手都點麻了,花了一天時間干活,又花了大半天時間做檢查。 然后,大家就一起討論這個事兒,這樣既費時費力,又無法保證正確的事情,我們該怎么解決呢? 解決方法 作為機(jī)智的程序員,一定可以解決這個問題的,因為我們都是很(ai)聰(tou)明(lan)的代碼者!!! 好吧,運(yùn)維利器PowerShell 命令又該出場了!掌聲在哪里? 作為需求分析員,只需要把上線數(shù)據(jù)準(zhǔn)備好,放到CSV文件里,如下: Tips:我這里把域名放在用戶名了,其實,更(tu)嚴(yán)(sheng)謹(jǐn)(shi)的情況,可以把域名放到代碼中: ? PowerShell 代碼 Tips:代碼邏輯很簡單,讀取CSV文件,找到站點的用戶組,一個一個添加就好了; ![]() Add-PSSnapin Microsoft.SharePoint.PowerShell #Read CSV file$CSVData = Import-CSV -path "C:\UserList.csv"#Set $WebUrl = "http://sitecollection/sites/PM"$GroupName = "PM Members"#Get the Web$web=Get-SPWeb $WebUrl#Get the SharePoint Group$Group= $web.Groups[$GroupName]#Loop every Row in the CSVforeach ($Row in $CSVData){ #Get UserName $userName = $row.UserName #Add User to the site collection $user = $web.EnsureUser($UserName)? #Add User to the Group $group.AddUser($user) Write-Host "Added User: " $row.UserName -ForegroundColor Green} ![]() 添加完畢以后的截圖(怎么這么少?測試數(shù)據(jù)啊,Small GeGe&Small JieJie們) 結(jié)束語 遇到困難,不要傷心,不要害怕,記得想起我們的運(yùn)(tou)維(lan)利器 PowerShell 命令。 Sharepoint 可以幫助企業(yè)用戶輕松完成日常工作。 |
溫馨提示:喜歡本站的話,請收藏一下本站!