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