The function accepts three parameters:
1. url points to url of the sharepoint site.
2. folder points to Document Library Name
3. Document points to the Path of the file.
function Upload-SPDocument([string]$url, [string]$Folder, [string]$Document) { $SPSite = New-Object Microsoft.SharePoint.SPSite($url) $OpenWeb = $SPSite.OpenWeb() $DocumentName = Split-Path $Document -Leaf $GetFolder = $OpenWeb.GetFolder($Folder) [void]$GetFolder.Files.Add("$Folder/$DocumentName",$((gci $Document).OpenRead()),"") $OpenWeb.Dispose() }
1 comment:
Fantastic1! this is the first example I found that worked. Thanks.
Post a Comment