powershell SharePoint Powershell添加列表项

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell SharePoint Powershell添加列表项相关的知识,希望对你有一定的参考价值。

#Add SharePoint PowerShell Snapin which adds SharePoint specific cmdlets
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue

    $webUrl = "http://spsvde001/twf"
    $listName = "Test Number Conv"
    # Open web and library
    $web = Get-SPWeb $webUrl
    $list = $web.Lists[$listName]
    
    $i = 0
for($i -eq 0;$i -lt 100;$i++){
    $Private:OFS = ""
    $PasswordLength = 5
    ##$InclChars = ‘abcdefghkmnprstuvwxyzABCDEFGHKLMNPRSTUVWXYZ123456789’
    $InclChars = "123456789"
    $RandomNums = 1..$PasswordLength | ForEach-Object { Get-Random -Maximum $InclChars.length }
    $RandomPassowrd = [String]$InclChars[$RandomNums]

    $ItemTitle = $RandomPassowrd

    $newItem = $list.AddItem()
    $newItem["TestNum"] = $ItemTitle
    $newItem.Update()
    write-host "****************************************"
    write-host "Item created"
}
#Dispose web
$web.Dispose()
#Add SharePoint PowerShell Snapin which adds SharePoint specific cmdlets
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue

    $webUrl = "http://spsvde001/twf"
    $listName = "Test Capitalization"
    # Open web and library
    $web = Get-SPWeb $webUrl
    $list = $web.Lists[$listName]
    
    $i = 0
for($i -eq 0;$i -lt 100;$i++){
    $Private:OFS = ""
    $PasswordLength = 10
    ##$InclChars = ‘abcdefghkmnprstuvwxyzABCDEFGHKLMNPRSTUVWXYZ123456789’
    $InclChars = ‘abcdefghkmnprstuvwxyz’
    $RandomNums = 1..$PasswordLength | ForEach-Object { Get-Random -Maximum $InclChars.length }
    $RandomPassowrd = [String]$InclChars[$RandomNums]

    $ItemTitle = $RandomPassowrd

    $newItem = $list.AddItem()
    $newItem["Title"] = $ItemTitle
    $newItem.Update()
    write-host "****************************************"
    write-host "Item created"
}
#Dispose web
$web.Dispose()
#Add SharePoint PowerShell Snapin which adds SharePoint specific cmdlets
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue
 
# Script settings
$webUrl = "http://portal.opwftg.com/teamsites/globalmanufacturing/CEP"
$listName = "CEPCertReportFields"

$ItemTitle = "EC DECLARATION OF CONFORMITY"
$Data = "NO SHOW"
$Model = "LE36"

# Open web and library
$web = Get-SPWeb $webUrl
$list = $web.Lists[$listName]

$newItem = $list.AddItem()
$newItem["Title"] = $ItemTitle
$newItem["Data"] = $Data
$newItem["Model"] = $Model
$newItem.Update()
write-host "****************************************"
write-host "Item created"
 
#Dispose web
$web.Dispose()

以上是关于powershell SharePoint Powershell添加列表项的主要内容,如果未能解决你的问题,请参考以下文章

powershell Powershell用于将Powershell与SharePoint 2007一起使用

powershell SharePoint Powershell添加列表项

powershell Sharepoint Powershell Snippets

powershell 为SharePoint 2013创建SharePoint服务帐户(最低)

使用 Powershell 插入 Sharepoint 凭据

powershell SharePoint事件接收器powershell脚本