SharePoint發(fā)行版本有SharePoint2003、SharePoint2007、Sharepoint 2010、SharePoint2013和SharePoint2016。SharePoint提供了功能強(qiáng)大的團(tuán)隊(duì)協(xié)作環(huán)境,使得組織能夠在整個(gè)組織內(nèi)部實(shí)現(xiàn)整合、組織、查找和提供 SharePoint站點(diǎn)。 最近,因?yàn)樾孪到y(tǒng)要上線,總是需要準(zhǔn)備數(shù)據(jù),把文檔里的數(shù)據(jù)導(dǎo)入到SharePoint 列表當(dāng)中,復(fù)制吧快速編輯功能還不給力,就想到寫個(gè)PowerShell 扔給BA去玩。 這里就舉個(gè)簡(jiǎn)單的列表,結(jié)構(gòu)如下: 我們需要的CSV文件結(jié)構(gòu)如下: 導(dǎo)入CSV到List的PowerShell 命令如下: ![]() Add-PSSnapin Microsoft.SharePoint.PowerShell #Read CSV file$CSVData = Import-CSV -path "D:\Data.csv" #Get SPWeb$web = Get-SPWeb -identity "http://sitecollection" #Get SPList$List = $web.Lists["ListName"] #Loop every Row in the CSVforeach ($Row in $CSVData){ #New SPListItem $Item = $List.Items.add() #Add SPColumn Value $item["Title"] = $row.Title $item["Name"] = $row.Name $item["Mark"] = $row.Mark $item.Update() Write-Host "Added: "$row.Name -ForegroundColor Green} ![]() PowerShell 執(zhí)行結(jié)果: 結(jié)束語 其實(shí),整個(gè)代碼思路是很簡(jiǎn)單的,讀取CSV文件里的所有行,然后循環(huán)插入到列表就好了。 如果運(yùn)維或者BA的命令行能力比較強(qiáng),自己都能夠搞定,因?yàn)檎Z法是標(biāo)準(zhǔn)的PowerShell 語法。 Sharepoint 可以幫助企業(yè)用戶輕松完成日常工作。 |
溫馨提示:喜歡本站的話,請(qǐng)收藏一下本站!