By using code similar to Upload file to SharePoint Document library using powershell I am able to upload file, but they are in checked out state then. This works without the SharePoint snapin.

Following the advice in the answer to the above question does not work, because similar to the OP over there I do not have a $SPfile object available.

I tried to follow other advice using $w = Get-SPweb ...;$w.getFolder, but this fails because the account running the script is not allowed to see the site, so Get-SPweb consistently fails. The user account is only allowed to access the document library.

I am looking for a way to nevertheless get the uploaded document checked in. I could imagine two possible solutions:

  1. Some GET request to the URL with sufficient parameters performs the check-in.
  2. Get a document library object without first using Get-SPweb and walking down from there to the file. Put simple: is there something like Get-SPlibrary that does not first run a Get-SPweb?

Any ideas?

1 Answer 1


If you mean uploading/checking-in a file from a client-side (i.e. without SP snap-in, without server-side model like Get-SPWeb or else), in SP2010, you may rely on the ASP.NET services (now deprecated).
You can, from PowerShell, call to Lists.CheckInFile Web service. Calling a Web service from PowerShell is simple, see for instance http://blog.robseder.com/2014/03/23/calling-a-soap-web-service-from-powershell-3-0/.

So, your code may look like (Windows integrated authentication, based on the current user logged on in PowerShell):

$proxy = New-WebServiceProxy -Uri  http://siteURL/_vti_bin/Lists.asmx?WSDL -UseDefaultCredential
$proxy.CheckInFile("http://SiteURL/DocLib/File.txt", "Completed revision.", "1");

Or, if you need to authenticate in Windows integrated but log on with a specific user:

$credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "DOMAIN\username", (ConvertTo-SecureString "password" -AsPlainText -Force)
$proxy = New-WebServiceProxy -Uri  http://siteURL/_vti_bin/Lists.asmx?WSDL -Credential $credentials
$proxy.CheckInFile("http://SiteURL/DocLib/File.txt", "Completed revision.", "1");

Note: From SP2013, you may use the REST API instead of the deprecated .asmx, as you can see at https://msdn.microsoft.com/en-us/library/office/dn292553.aspx#Files.

  • The New-WebServiceProxy always comes back with a 401 :-( My hunch is, that it is a similar access right problem. I think now that I have to resort to get the customer to change the access rights accordingly.
    – Harald
    Commented Oct 12, 2015 at 10:36
  • 1. You'll never get an elevated access from a client code (e.g. Web service call). 2. Your problem may simply be related to absence of authentication in your Web service client call. What's the SP authentication mode? If Windows integrated AND your PowerShell in started as the user you want, you may simply add $proxy.UseDefaultCredentials = $true
    – Evariste
    Commented Oct 12, 2015 at 10:52
  • I edited my anwser to include authentication.
    – Evariste
    Commented Oct 12, 2015 at 10:56
  • YES!, this worked. You may want to add two small edits to your answer: The method is actually called CheckInFile and I call New-WebServiceProxy -UseDefaultCredential. Using $proxy.UseDefaultCredentials did not work since I got the 401 already when requesting the WSDL.
    – Harald
    Commented Oct 12, 2015 at 11:06
  • Thank you for the feedback, I updated the answer accordingly.
    – Evariste
    Commented Oct 12, 2015 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.