Skip to main content
deleted 80 characters in body
Source Link
    Add-PSSnapin microsoft.sharepoint.powershell
    $web = Get-SPWeb "http://dc01:9876"
    $lst = $web.Lists.TryGetList("Style Library")
    $DirLoc = "C:\Work\Style Library\20April2015"
    
      
$relativeUrl = $lst.RootFolder.ServerRelativeUrl;
    
      
function UploadToLibrary($spurl,$filepath){
        Get-ChildItem -path $filepath -Directory |ForEach-Object {
            $FldrName=($spurl,$_.Name -join "/")
            $CheckFolder= $web.GetFolder($FldrName)
            if(-not $CheckFolder.Exists)
            {
                $tmp=$web.GetFolder($spurl).SubFolders.Add($FldrName);
            }
            UploadToLibrary ($spurl,$_.Name -join "/") ($filepath,$_.Name -join "\") 
        }
        $FilesToAdd=$web.GetFolder($spurl)
        Get-ChildItem -path $filepath -File |ForEach-Object {
            $_.FullName
            $bytes = [System.IO.File]::ReadAllBytes($_.FullName)
            $x=$FilesToAdd.Files.Add($_.Name,$bytes,$true);
        }
    }
    
      
UploadToLibrary $relativeUrl $DirLoc
    Add-PSSnapin microsoft.sharepoint.powershell
    $web = Get-SPWeb "http://dc01:9876"
    $lst = $web.Lists.TryGetList("Style Library")
    $DirLoc = "C:\Work\Style Library\20April2015"
    
     $relativeUrl = $lst.RootFolder.ServerRelativeUrl;
    
     function UploadToLibrary($spurl,$filepath){
        Get-ChildItem -path $filepath -Directory |ForEach-Object {
            $FldrName=($spurl,$_.Name -join "/")
            $CheckFolder= $web.GetFolder($FldrName)
            if(-not $CheckFolder.Exists)
            {
                $tmp=$web.GetFolder($spurl).SubFolders.Add($FldrName);
            }
            UploadToLibrary ($spurl,$_.Name -join "/") ($filepath,$_.Name -join "\") 
        }
        $FilesToAdd=$web.GetFolder($spurl)
        Get-ChildItem -path $filepath -File |ForEach-Object {
            $_.FullName
            $bytes = [System.IO.File]::ReadAllBytes($_.FullName)
            $x=$FilesToAdd.Files.Add($_.Name,$bytes,$true);
        }
    }
    
     UploadToLibrary $relativeUrl $DirLoc
Add-PSSnapin microsoft.sharepoint.powershell
$web = Get-SPWeb "http://dc01:9876"
$lst = $web.Lists.TryGetList("Style Library")
$DirLoc = "C:\Work\Style Library\20April2015"
         
$relativeUrl = $lst.RootFolder.ServerRelativeUrl;
         
function UploadToLibrary($spurl,$filepath){
    Get-ChildItem -path $filepath -Directory |ForEach-Object {
        $FldrName=($spurl,$_.Name -join "/")
        $CheckFolder= $web.GetFolder($FldrName)
        if(-not $CheckFolder.Exists)
        {
            $tmp=$web.GetFolder($spurl).SubFolders.Add($FldrName);
        }
        UploadToLibrary ($spurl,$_.Name -join "/") ($filepath,$_.Name -join "\") 
    }
    $FilesToAdd=$web.GetFolder($spurl)
    Get-ChildItem -path $filepath -File |ForEach-Object {
        $_.FullName
        $bytes = [System.IO.File]::ReadAllBytes($_.FullName)
        $x=$FilesToAdd.Files.Add($_.Name,$bytes,$true);
    }
}
         
UploadToLibrary $relativeUrl $DirLoc
deleted 32 characters in body
Source Link
    Add-PSSnapin microsoft.sharepoint.powershell
    $web = Get-SPWeb "http://dc01:9876"
    $lst = $web.Lists.TryGetList("Style Library")
    $DirLoc = "C:\Work\Style Library\20April2015"
    
    $relativeUrl = $lst.RootFolder.ServerRelativeUrl;
    
    function UploadToLibrary($spurl,$filepath){
        Get-ChildItem -path $filepath -Directory |ForEach-Object {
            $FldrName=($spurl,$_.Name -join "/")
            $CheckFolder= $web.GetFolder($FldrName)
            if(-not $CheckFolder.Exists)
            {
                $tmp=$web.GetFolder($spurl).SubFolders.Add($FldrName);
            }
            UploadToLibrary ($spurl,$_.Name -join "/") ($filepath,$_.Name -join "\") 
        }
        $FilesToAdd=$web.GetFolder($spurl)
        Get-ChildItem -path $filepath -File |ForEach-Object {
            $_.FullName
            $bytes = [System.IO.File]::ReadAllBytes($_.FullName)
            $x=$FilesToAdd.Files.Add($_.Name,$bytes,$true);
            $x.CheckIn("")
        }
    }
    
    UploadToLibrary $relativeUrl $DirLoc
    Add-PSSnapin microsoft.sharepoint.powershell
    $web = Get-SPWeb "http://dc01:9876"
    $lst = $web.Lists.TryGetList("Style Library")
    $DirLoc = "C:\Work\Style Library\20April2015"
    
    $relativeUrl = $lst.RootFolder.ServerRelativeUrl;
    
    function UploadToLibrary($spurl,$filepath){
        Get-ChildItem -path $filepath -Directory |ForEach-Object {
            $FldrName=($spurl,$_.Name -join "/")
            $CheckFolder= $web.GetFolder($FldrName)
            if(-not $CheckFolder.Exists)
            {
                $tmp=$web.GetFolder($spurl).SubFolders.Add($FldrName);
            }
            UploadToLibrary ($spurl,$_.Name -join "/") ($filepath,$_.Name -join "\") 
        }
        $FilesToAdd=$web.GetFolder($spurl)
        Get-ChildItem -path $filepath -File |ForEach-Object {
            $_.FullName
            $bytes = [System.IO.File]::ReadAllBytes($_.FullName)
            $x=$FilesToAdd.Files.Add($_.Name,$bytes,$true);
            $x.CheckIn("")
        }
    }
    
    UploadToLibrary $relativeUrl $DirLoc
    Add-PSSnapin microsoft.sharepoint.powershell
    $web = Get-SPWeb "http://dc01:9876"
    $lst = $web.Lists.TryGetList("Style Library")
    $DirLoc = "C:\Work\Style Library\20April2015"
    
    $relativeUrl = $lst.RootFolder.ServerRelativeUrl;
    
    function UploadToLibrary($spurl,$filepath){
        Get-ChildItem -path $filepath -Directory |ForEach-Object {
            $FldrName=($spurl,$_.Name -join "/")
            $CheckFolder= $web.GetFolder($FldrName)
            if(-not $CheckFolder.Exists)
            {
                $tmp=$web.GetFolder($spurl).SubFolders.Add($FldrName);
            }
            UploadToLibrary ($spurl,$_.Name -join "/") ($filepath,$_.Name -join "\") 
        }
        $FilesToAdd=$web.GetFolder($spurl)
        Get-ChildItem -path $filepath -File |ForEach-Object {
            $_.FullName
            $bytes = [System.IO.File]::ReadAllBytes($_.FullName)
            $x=$FilesToAdd.Files.Add($_.Name,$bytes,$true);
        }
    }
    
    UploadToLibrary $relativeUrl $DirLoc
Source Link

    Add-PSSnapin microsoft.sharepoint.powershell
    $web = Get-SPWeb "http://dc01:9876"
    $lst = $web.Lists.TryGetList("Style Library")
    $DirLoc = "C:\Work\Style Library\20April2015"
    
    $relativeUrl = $lst.RootFolder.ServerRelativeUrl;
    
    function UploadToLibrary($spurl,$filepath){
        Get-ChildItem -path $filepath -Directory |ForEach-Object {
            $FldrName=($spurl,$_.Name -join "/")
            $CheckFolder= $web.GetFolder($FldrName)
            if(-not $CheckFolder.Exists)
            {
                $tmp=$web.GetFolder($spurl).SubFolders.Add($FldrName);
            }
            UploadToLibrary ($spurl,$_.Name -join "/") ($filepath,$_.Name -join "\") 
        }
        $FilesToAdd=$web.GetFolder($spurl)
        Get-ChildItem -path $filepath -File |ForEach-Object {
            $_.FullName
            $bytes = [System.IO.File]::ReadAllBytes($_.FullName)
            $x=$FilesToAdd.Files.Add($_.Name,$bytes,$true);
            $x.CheckIn("")
        }
    }
    
    UploadToLibrary $relativeUrl $DirLoc