Kis*_*han 4 powershell sharepoint powershell-2.0 sharepoint-2010 powershell-3.0
我想将相同的文件上传到所有网站集中具有相同层次结构的多个网站集.我想使用PowerShell并包含自动签入/签出功能.
我能够在SharePoint中上传文件.下面是代码.:
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null
# create the Variable Path and Pass the source folder path
$path = “D:\ABC\DEF\26Nov\”;
# create the Variable destination and pass the URL of the SharePoint List
$destination = "complete URL of File will be mentioned here";
# Store the current user default credentials in the Variable Credentials
$credentials = [System.Net.CredentialCache]::DefaultCredentials;
# Create the object of the Webclient
$webclient = New-Object System.Net.WebClient;
# Pass the user credentials
$webclient.Credentials = $credentials; Get-ChildItem
# “For Each” loop will upload all of the files one by one onto the destination using the UploadFile method
Get-ChildItem $path | ForEach-Object { $webclient.UploadFile($destination + “/” + $_.Name, “PUT”, $_.FullName)};
通过此代码,文件已上载但已签出.我想让它自动检查.如果文件在那里,则首先自动签出然后签入.
请帮助我,因为我已经花了2天时间.但没有任何反应非常感谢您的支持
问候
基尚
小智 8
这里是外行样式的简单脚本,经过测试并可以很好地将文件从驱动器上传到SharePoint文档库
http://soreddymanjunath.blogspot.in/2014/07/add-file-to-document-library-using.html
cls
asnp "*sh*"
$url=Read-Host "Enter Site Url" 
$web=Get-SPWeb -Identity $url
if($web)
{
try
{
$list = $web.Lists.TryGetList("Documents")
$files = Get-ChildItem -Path "D:\Manju" -Force -Recurse
    foreach ($file in $files)
    {
      $stream = $file.OpenRead()
      $done= $list.RootFolder.Files.Add($file.Name, $stream, $true)
      Write-Host $done.Name  "Uploaded into the Site" -BackgroundColor Green         
    }
}
catch
{
$ErrorMessage = $_.Exception.Message
Write-Host $ErrorMessage
}
}
else
{
Write-Host "Site Doesn't exist"
}
$list.Update();
| 归档时间: | 
 | 
| 查看次数: | 37199 次 | 
| 最近记录: |