• PowerShell Download files from a library


    # Check to ensure Microsoft.SharePoint.PowerShell is loaded
    $Snapin = get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
    if($Snapin -eq $null){
        Write-host "Loading SharePoint Powershell Snapin"
        Add-PSSnapin "Microsoft.SharePoint.Powershell"
    }
    $web = Get-SPWeb -Identity http://gdcvmg_sps01
    write-host $web
    $destination = "C:\\test2\\"
    $list = $web.GetList("document lib test2")
    function ProcessFolder {
        param($folderUrl)
        $folder = $web.GetFolder($folderUrl)
        foreach ($file in $folder.Files) {
            #Ensure destination directory
            $destinationfolder = $destination + "/" + $folder.Url 
            if (!(Test-Path -path $destinationfolder))
            {
                $dest = New-Item $destinationfolder -type directory 
            }
            #Download file
            $binary = $file.OpenBinary()
            $stream = New-Object System.IO.FileStream($destinationfolder + "/" + $file.Name), Create
            $writer = New-Object System.IO.BinaryWriter($stream)
            $writer.write($binary)
            $writer.Close()
        }
    }
    
    #Download root files
    ProcessFolder($list.RootFolder.Url)
    #Download files in folders
    foreach ($folder in $list.Folders) {
        ProcessFolder($folder.Url)
    }
    

      

  • 相关阅读:
    接口和抽象类的异同点
    实体对象间传值克隆
    什么是反射&反射的8个类的用法
    ERP中反射的两个实例
    基础02 Java 跨平台原理
    基础01 dos命令
    lists删除
    多字段 java对象排序
    Java对象排序
    MySQL表中数据的迁移
  • 原文地址:https://www.cnblogs.com/ilawrence/p/2889301.html
Copyright © 2020-2023  润新知