Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8419239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:33:29+00:00 2026-06-10T02:33:29+00:00

Objective : programmatically upload documents to Sharepoint Issues : When trying to use :

  • 0

Objective : programmatically upload documents to Sharepoint

Issues :

  1. When trying to use : [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") it does not error but it does error when I try to use the objects it contains. Such as New-Object Microsoft.SharePoint.SPSite($url). The fix to this is to download the “Microsoft.Sharepoint.dll” which is contained in the web extensions folder on the actual server the MOSS is installed on. The problem with that is to be running these scripts on the 2008 server that hosts our Sharepoint site is in no way ‘practical’ in a big company.

  2. My second approach was to use an internet explorer com object to physically navigate to the page and upload the file from there. After getting the ID of the text box I am not able to set the value, due to what my research shows as “security measures” by Microsoft. when using the get-member cmdlet I am able to see that this html element has a field value that is supposedly ‘System.String value {get;set;}’. When I try to set the value nothing happens. The text box itself on the website does not allow you to type anything in. Instead the text box is clickable and brings up a “choose file to upload” window. If I manually choose a file to upload without submitting it, go back to the ISE and and do $uploadText.Value it spits out the file I just chose to console.

  3. My third ditch effort was to use the sendkeys object found in VB to send the path to the web browser and upload the file that way. But when running it the program just hangs and never sends it. This strategy I found at : http://technet.microsoft.com/en-us/library/ff731008 was described to be “a little … temperamental ….”. I first make the $ie object open the Microsoft file browser and then try to send keys to it.

The attempted code : (using IE com object, AppActivate and Sendkeys):

$spURL = "https://SharepointSite"
[void] [System.Reflection.Assembly]::LoadWithPartialName("'Microsoft.VisualBasic")
$ie = new-object -com "InternetExplorer.Application"
$ie.visible = $true
$ie.navigate2($spURL)
while($ie.Busy -eq $true) {Start-Sleep 1}
($ie.Document.GetElementByID("zz16_UploadMenu")).click()
while($ie.Busy -eq $true) {Start-Sleep 1}
$uploadText = $ie.Document.GetElementByID("ctl00_PlaceHolderMain_ctl01_ctl02_InputFile")
[Microsoft.VisualBasic.Interaction]::AppActivate("Upload Document")
$uploadText.value = "C:\uploadFile.xlsx" #this line does nothing
$uploadText.click() ## opens up "choose file to upload"
[void] [System.Reflection.Assembly]::LoadWithPartialName("'System.Windows.Forms")
[System.Windows.Forms.SendKeys]::SendWait("C:\uploadFile.xlsx")

And that is it, the browser box pops up, and the script never ends. I have found that some other people have had trouble with setting AppActivate to “choose file to upload” (which I had it set to before I changed it to the IE title “Upload Document”). These problems were all in VB though, I did find what someone claimed to be a fix to “Referencing a Microsoft HTML Library” but it is only going to work for VB, and I need this in powershell. That fix can be found here but it does not work for me.

It seems Microsoft just does not want me to be uploading files programmatically. But before I deemed this “Impossible” I just wanted to post it here first. Any help would be greatly appreciated, I thought everything was possible with powershell! 😀

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:33:30+00:00Added an answer on June 10, 2026 at 2:33 am

    Due to Security reasons you can’t do a Fileupload with Comobject IE

    I solved that issue by using the watin dll within PS.

    I can’t Access my Sample from here but you find all you Need at http://www.watin.org

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to upload a file to SharePoint programmatically via a Mac Application that
I need to programmatically solve a system of linear equations in C, Objective C,
I am programmatically creating a tableview in objective c. How can I make the
Would you call this implementation of a multiton in objective-c 'elegant'? I have programmatically
Objective-C uses a sophisticated message-passing system when one object calls a method on another
In Cocoa/ Objective C I need to be able to programmatically find out which
How can I programmatically scroll a UIWebView in Objective-C (iOS)? The only solution I
Is it possible to programmatically get the properties of an object in objective-c without
we can easily capture a view(screenshot) programmatically in iPhone. But i am trying to
How can I programmatically (Objective-C) whether an iPad has a Retina display?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.