Upload File to SharePoint using Web Services and PowerShell
Requirement: For a file upload issue troubleshooting, had to call SharePoint web services to Upload a file into SharePoint document library.
Upload File to SharePoint Library using Web Services - PowerShell
Here is my PowerShell script to upload file to SharePoint document library using web services:
Upload File to SharePoint Library using Web Services - PowerShell
Here is my PowerShell script to upload file to SharePoint document library using web services:
$SourceFile = "D:\Reports\MonthlyRpt-Jan14.csv" $DestinationPath ="http://operations.crescent.com/Reports/MonthlyRpt-Jan14.csv" $WebServiceURL = "http://operations.crescent.com/_vti_bin/copy.asmx?WSDL" $CopyWebService = new-WebServiceProxy -Uri $WebServiceURL -UseDefaultCredential #For custom Credentials, use: #$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList @($UserName,$SecurePasssword) #$UserName = "Domain\UserName" #$Password = "PASSWORD" #$SecurePasssword = ConvertTo-SecureString -String $Password -AsPlainText -Force #$CopyWebService= new-WebServiceProxy -Uri $WebServiceURL -Credential $cred #Get the File from Disk $FileData = [System.IO.File]::ReadAllBytes($SourceFile) #Get Filename $FileName = [System.IO.Path]::GetFileName($SourceFile).ToString() $Metadata = @() $results = $null #Upload file to SharePoint library using Web Service $ret= $CopyWebService.CopyIntoItems($FileName, $DestinationPath, $Metadata, $FileData, [ref]$results) Write-host "Upload Status:" $results[0].ErrorCode
Great!!! It worked.Thanks a lot.
ReplyDeleteanything for Sharepoint sites that are https and use ADFS
ReplyDelete