Uploading document using Powershell is throwing error- There is no file with URL

Hi.
I am trying to upload multiple documents to a sub folder in a library using powershell.
I am getting the error as : ForEach-Object : Exception calling "Add" with "3" argument(s):
"<nativehr>0x80070003</nativehr><nativestack></nativestack>There is no file
with URL 'server/TestLibrary/User_image/ab_3f_wht_ist_small_gif.gif' in this Web."
I have used the below code:
function UploadImages($weburl)
$docLibraryName = "TestLibrary"
$localFolderPath = "C:\Users\Imgs\user_image"
Add-PsSnapin Microsoft.SharePoint.PowerShell -erroraction silentlycontinue
$web = Get-SPWeb -Identity $webUrl
$docLibrary = $web.Lists[$docLibraryName]
$subFolderName="user_image"
Add-PsSnapin Microsoft.SharePoint.PowerShell -erroraction silentlycontinue
$web = Get-SPWeb -Identity $webUrl
$docLibrary = $web.Lists[$docLibraryName]
#Attach to local folder and enumerate through all files
$files = ([System.IO.DirectoryInfo] (Get-Item $localFolderPath)).GetFiles() | ForEach-Object {
#Create file stream object from file
$fileStream = ([System.IO.FileInfo] (Get-Item $_.FullName)).OpenRead()
$contents = new-object byte[] $fileStream.Length
$fileStream.Read($contents, 0, [int]$fileStream.Length);
$fileStream.Close();
write-host "Copying" $_.Name "to" $docLibrary.Title "in" $web.Title "..."
#Add file
$folder = $web.getfolder($docLibrary.Title + "/" + $subFolderName)
write-host "folder is " $folder
$spFile = $folder.Files.Add($folder.Url + "/" + $_.Name, $contents, $true)
$spItem = $spFile.Item
Write-Host -f Green "Added Images to Library !!!"
$web.Dispose()
How to fix this?
Thanks

HI,
Is the name of the image or the sub folder name the issue?
I have the images with the name as "ab_3f_wht_ist_small_gif.gif".  folder name "User_image"
There are underscores on the file name, but there is no space. When I add the file from the library (using the UI), the image is getting added.
But adding through the powershell is giving the issue.
I have checked this:
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/e810ad03-81ef-4fa6-aab8-ddc896a13ebf/getting-error-during-uploading-a-document-using-powershell?forum=sharepointdevelopmentprevious
but did not help.
Thanks

Similar Messages

  • Powershell: There is no file with URL error during file upload.

    I am trying to put together a PowerShell script that I could use to upload files from a local directory, into a Document Library in a Record Center Site. Here is what my script looks like...
    #Open web and library
    $web = Get-SPWeb $webUrl
    $docLibrary = $web.Lists[$docLibraryName]
    $files = ([System.IO.DirectoryInfo] (Get-Item $localFolderPath)).GetFiles()
    Write-Host "Local Directory:" $localFolderPath
    ForEach($file in $files)
    Write-Host "Looping through files"
    Write-Host "Current file:" $file
    ElseIf ($contentType = "MyContentType")
    #Open file
    $fileStream = ([System.IO.FileInfo] (Get-Item $file.FullName)).OpenRead()
    # Gather the file name
    $FileName = $File.Name
    #remove file extension
    $NewName = [IO.Path]::GetFileNameWithoutExtension($FileName)
    #split the file name by the "-" character
    $FileNameArray = $NewName.split("_")
    $check = $FileNameArray.Length
    #Add file
    $folder = $web.getfolder($docLibraryUrlName)
    write-host "Copying file " $file.Name " to " $folder.ServerRelativeUrl "..."
    $spFile = $folder.Files.Add($folder.Url + "/" + $file.Name, [System.IO.Stream]$fileStream, $true)
    $spItem = $spFile.Item
    write-host "Success"
    #populate columns
    $spItem["Application Number"] = $FileNameArray[0].ToString()
    $spItem["Site Number"] = $FileNameArray[1].ToString()
    $spItem.Update()
    $fileStream.Close();
    Each time I run my script, I get this error message 
    Exception calling "Add" with "3" argument(s): "<nativehr>0x80070003</nativehr><nativestack></nativestack>There is no file with URL 'http://myRecordLibrarySite/myRecord Library/12587_B2317.PDF' in this Web."
    At C:\powershellscripts\Upload-FilesIntoSharePoint.ps1:72 char:6
    +                     $spFile = $folder.Files.Add($folder.Url + "/" + $file.Name, [System.IO.Stre ...
    +    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : DirectoryNotFoundException
    I have not been able to nail down why the script is failing. Any ideas why? Thanks for the help.

    I just figured out the issue with adding the file. I went in this direction, and my code has progressed forward.
    $folder = $web.getfolder($docLibrary.rootFolder.URL)

  • OneNote 2013 throwing error: There is a problem with your account. Please try again later on Windows 8.1

    Hi
    I had Windows 8 installed on my corporate laptop till last week and as the OS crashed, I have re-installed the system with 8.1 and it has Office 2013 installed with my corporate ID. It is signed in Corporate credentials by default. But when I am trying to
    use Switch Account option and trying to login with my Microsoft ID to sync my notebooks, it throws an error : "There is a problem with your account. Please try again later".
    Note that My Microsoft is active and i am able to access the pages online.
    Pls help with me with a resolution

    Hi Raj_Tan,
    Thank you for posting this issue on the TechNet community forums.
    From the description I understand that you're having problems signing into OneNote 2013 with your Microsoft account and that it's giving you an error: "There is a problem with your account. Please try again later". You mentioned you are able to
    access the pages online.
    Could you please try the following:
    Check if you are able to login to other office apps with your Microsoft account.
    Check if you are able to login to the OneDrive app using your Microsoft account.
    Try emptying all saved passwords from the credential manager:
    http://windows.microsoft.com/en-GB/windows7/remove-stored-passwords-certificates-and-other-credentials
    Although this link applies to Windows 7, the process is the same in Windows 8.

  • How do I bulk upload documents using PowerShell and extract metadata from file name?

    I have a requirement to upload a bunch of documents into a document library. Based on the content type, the rules of updating the metadata is different...the one giving me trouble is to extract the metadata from the file name. If I have a file name like
    "part1_part2_part3.pdf" how do I extract part1, part2, part3 and tag each document being uploaded into SharePoint, using PowerShell? I have searched and have not been able to find anything to get me started.
    Has anyone done this before? Or is there a blog I can take a look at? Thanks
     

    You will have to write a PS script encompassing this logic.
    Read files from the folder using
    Get-Item cmdlet
    Determine the content type based on the path or filename.
    Split the file name to extract the tag names.
    If the metadata fields in the content type is a managed metadata field, check whether the term exists and set it.
    Updating SharePoint Managed Metadata Columns
    with PowerShell
    This post is my own opinion and does not necessarily reflect the opinion or view of Slalom.

  • I am trying to upload documents using Mass Transit but I am getting an Error:"[-192]" message. How can I fix this?

    I am trying to upload documents using Mass Transit but I am getting an Error:"[-192]" message. What is this error? How can I fix this?
    Thank you,

    I've never heard of that product before, but it seems to be, among other things, a 32-bit browser plugin. If that's the part you're having trouble with, quit your browser (e.g., Safari), select its icon in the Applications folder, open the info window, and check the box labeled "Open in 32-bit mode." Relaunch the browser and try again. If that doesn't help, contact the developer for support.

  • I am using Mac OS X 10.7.5 as of now and when I am trying to upgrade to Mavericks, it is throwing error "The product distribution file could not be verified. It may be damaged or not signed".

    I am using Mac OS X 10.7.5 as of now and when I am trying to upgrade to Mavericks, the App Store is throwing error "The product distribution file could not be verified. It may be damaged or not signed".
    Is there anything I should do differently? Is anyone else facing the same issue?
    Kindly help.

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It won’t solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    Third-party system modifications are a common cause of usability problems. By a “system modification,” I mean software that affects the operation of other software — potentially for the worse. The following procedure will help identify which such modifications you've installed. Don’t be alarmed by the complexity of these instructions — they’re easy to carry out and won’t change anything on your Mac. 
    These steps are to be taken while booted in “normal” mode, not in safe mode. If you’re now running in safe mode, reboot as usual before continuing. 
    Below are instructions to enter some UNIX shell commands. The commands are harmless, but they must be entered exactly as given in order to work. If you have doubts about the safety of the procedure suggested here, search this site for other discussions in which it’s been followed without any report of ill effects. 
    Some of the commands will line-wrap or scroll in your browser, but each one is really just a single line, all of which must be selected. You can accomplish this easily by triple-clicking anywhere in the line. The whole line will highlight, and you can then copy it. The headings “Step 1” and so on are not part of the commands. 
    Note: If you have more than one user account, Step 2 must be taken as an administrator. Ordinarily that would be the user created automatically when you booted the system for the first time. The other steps should be taken as the user who has the problem, if different. Most personal Macs have only one user, and in that case this paragraph doesn’t apply. 
    Launch the Terminal application in any of the following ways: 
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.) 
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens. 
    ☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid. 
    When you launch Terminal, a text window will open with a line already in it, ending either in a dollar sign (“$”) or a percent sign (“%”). If you get the percent sign, enter “sh” and press return. You should then get a new line ending in a dollar sign. 
    Step 1 
    Triple-click anywhere in the line of text below on this page to select it:
    kextstat -kl | awk '!/com\.apple/{printf "%s %s\n", $6, $7}' | open -ef 
    Copy the selected text to the Clipboard by pressing the key combination command-C. Then click anywhere in the Terminal window and paste (command-V). I've tested these instructions only with the Safari web browser. If you use another browser, you may have to press the return key after pasting. A TextEdit window will open with the output of the command. If the command produced no output, the window will be empty. Post the contents of the TextEdit window (not the Terminal window), if any — the text, please, not a screenshot. You can then close the TextEdit window. The title of the window doesn't matter, and you don't need to post that. No typing is involved in this step.
    Step 2 
    Repeat with this line:
    { sudo launchctl list | sed 1d | awk '!/0x|com\.(apple|openssh|vix\.cron)|org\.(amav|apac|cups|isc|ntp|postf|x)/{print $3}'; echo; sudo defaults read com.apple.loginwindow LoginHook; echo; sudo crontab -l; } 2> /dev/null | open -ef 
    This time you'll be prompted for your login password, which you do have to type. Nothing will be displayed when you type it. Type it carefully and then press return. You may get a one-time warning to be careful. Heed that warning, but don't post it. If you see a message that your username "is not in the sudoers file," then you're not logged in as an administrator. 
    Note: If you don’t have a login password, you’ll need to set one before taking this step. If that’s not possible, skip to the next step. 
    Step 3
    { launchctl list | sed 1d | awk '!/0x|com\.apple|org\.(x|openbsd)/{print $3}'; echo; crontab -l 2> /dev/null; } | open -ef 
    Step 4
    ls -A /e*/{cr,la,mach}* {,/}Lib*/{Ad,Compon,Ex,Fram,In,Keyb,La,Mail/Bu,P*P,Priv,Qu,Scripti,Servi,Spo,Sta}* L*/Fonts .la* 2> /dev/null | open -ef  
    Important: If you formerly synchronized with a MobileMe account, your me.com email address may appear in the output of the above command. If so, anonymize it before posting. 
    Step 5
    osascript -e 'tell application "System Events" to get name of login items' | open -ef 
    Remember, steps 1-5 are all copy-and-paste — no typing, except your password. Also remember to post the output. 
    You can then quit Terminal.

  • Uploading documents using CFFile

    I am using CFFile for uploading documents using Cold Fusion 8
    in my Intranet environment. Each record has a limit of 20 documents
    that can be uploaded into MySQL database. It seems if I upload
    mulitple documents at around 1mb it takes less than a minute to
    complete. The problem seems to be when I upload muliptle documents
    that are bigger.
    If I attempt to upload 2 documents each over 25mb it takes
    around 10 minutes.
    Anyone have suggestions on alternatitve way to do this or
    should I just limit size of each upload to 4mb and less?

    Isn't this just a product of your internet speed and the size
    of the upload?

  • How to Upload documents using Gateway Service in SAP UI5?

    Hi Team,
    How to upload documents using Gateway Service in UI5 app.
    This is Attachment Functionality.using Gateway Service in Controller.JS/View.JS.
    Thanks in Advance.
    Regards,
    Satya

    Hi,
    I suggest you use the search function on scn/google...
    Anyways, here are some usefull links:
    How To Upload and Download Files Using SAP NW Gateway SP06
    Uploading files to SAP using HTML5 /AJAX/Gateway media links with real-time progress bar
    Kind regards,
    RW

  • I have just purchased a MacBook Pro and iWork's. when I try to upload documents using iCloud, it now wants me to purchase iWorks for iOS ? Do I need to purchase both versions?

    I have just purchased a MacBook Pro and iWork's. When I try to upload documents using iCloud, it now wants me to purchase iWorks for iOS ? Do I need to purchase both versions?

    To be able to use documents at iCloud.com, you need at least one iOS device that uses the same account with at least one of the iWork apps installed.

  • I am trying to install iTunes on my PC, but I get this error: "There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support personnel or package vendor." Help!

    I am trying to install iTunes on my PC (using Windows 8.1), but I get this error: "There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support personnel or package vendor." The iTunes file (64-bit) I am trying to install, is named "iTunes64Setup.exe". What seems to be the problem? Help!

    Hey madnest,
    Thanks for the question. After reviewing your post, it sounds like you are having difficulty installing iTunes in Windows. I would recommend that you read this article, it may be able to help you resolve or isolate the issue.
    Issues installing iTunes or QuickTime for Windows
    Thanks for using Apple Support Communities.
    Have a nice day,
    Mario

  • J2ee1.4 installation error - there are no files requiring installation

    hi all,
    i downloaded the j2ee sdk 1.4 bundle and installed successfully on my suse 8.2. however when i tried doing it on another suse 8.2 machine using the same bundle i got an error that says :
    There are no files requiring installation - here's all the output -
    Checking available disk space...
    Checking Java(TM) 2 Runtime Environment...
    Launching Java(TM) 2 Runtime Environment...
    Error: There are no files requiring installation.
    Deleting temporary files...
    i'm new to j2ee so plz, if any one knows how to get around this, let me know.
    thanks,
    rich

    This message will be issued if files necessary for installation are not found once the self-extracting executable extracts its content. If you successfully used same distribution file to install on another machine, it is very likely that the distribution file got corrupted while being moved from one system to another.
    If you use ftp to transfer files between systems, make sure that you transfer file in binary mode.
    If you don't have the original distribution file anymore, you might need to download the distribution again.

  • When installing itunes 10 uding windows xp I get the following error: "There is a problem with this Windows Installerpackage. A program run as part of the setup did not finish as expected. Contact your sipport personnel or package vendor." - any ideas?

    When downloading itunes 10 in windows xp, I get the following error "There is a problem with this Windoes Installer package. Aprogram run as part of the setup did not finish as expected. Contact your support personnel or package vendor." - any ideas on how to proceed?

    using MSICUU2.exe didn't help me.  But,  the new replacement app did:
      http://support.microsoft.com/mats/Program_Install_and_Uninstall
    I fixed my problem like this:
    Here's the deal - 
    1.  can you install itunes via the APPLE SOFTWARE updater?
    I couldn't  so I downloaded ITUNES and tried to install it that way.   Hence  I got the same error hang as you.  Nothing worked,  (Multiple attempts at uninstall reinstall,  stopping of Services,  Reg cleaners  etc..)
    2.  If answer is NO to #1 you must fixe the APPLE SOFTWARE UPDATE Program. 
    OK  so I couldn't find a Download for this.   But:  if you have WINRAR,  open the ITUNES.EXE and extract the APPLESOFTWAREUPDATE.MSI file.  Execute the APPLESOFTWAREUPDATE.MSI separately.   And you will not be able to install it and have a similar issue as per your Itunes install.   This of course leads you to believe that the Itunes.exe  install is also installing all of these components including the applesoftwareupdate silently.   It must BOMB at that portion of the install and you are done. 
    3.  Your goal now is to get the applesoftwareupdate installed.   How do you do this.  Well -  here is what I did.
      a.  downloaded and RUN a PC  Installer FIX it tool from Microsoft.  This is a replacement for the older MSI fixer they used to use.
      http://support.microsoft.com/mats/Program_Install_and_Uninstall
    b. It will list programs to attempt to fix.
      choose  AppleSoftwareUpdate.msi
    c. Once it is done,  then reinstall apple program updater using
    AppleSoftwareUpdate.msi
    Finally it should install since the Microsoft tool appraently fixed corrupted installation files in your registry for this application.
    (Please note:  that I also disabled any apple related services such as BONJOUR or IPOD DEvice RUN:  services.msc to get there -  although this man not be necesarry.)
    Hence Launch this APPLE UPDATE SOFTWARE (Click the ICON in your Start menu)  it should list ITUNES
    select ITUNES from here and it will update.
    KEY HERE is to ONLY UPDATE APPLE Stuff via the APPLE SOFTWARE UPDATE program.  If that program is not working fix it.  Then Bingo.
    I am sorry to see folks having this problem for weeks.  
    APPLE,   Spread the word.  PC's can get corruption in the registry on your product should the update be stopped or computer shut off during an update.  etc...   Please improve your software updater program to check for invalid registry upon launching the app.  This will prevent people thinking it is an APPLE issue.  It appears to be a problem on your PC's registry settings for the APPLE Software update.
    Bruno Ricci

  • Error: "There is a problem With Adobe Acrobat/Reader..." What is .MST file??

    I get the following error message and I looked it up in the knowledge base, and there was a solution for fixing the error message. However, I have no idea what they are talking about. I have downloaded the Customization Wizard, but I have no clue what the following means:
    A) Create a new transform
    B) Open your previously created .mst file
    I went into the C Drive and opened Program Files. I found the Adobe folder, but I couldn't find an .mst file anywhere. Am I completely lost??? Below is the knowledge base solution:
    Error: "There is a problem With Adobe Acrobat/Reader..." when you view a PDF in a browser (Acrobat and Adobe Reader 8 on Windows)
    Issue
    When you try to view a PDF in Internet Explorer, you see the error message, "There is a problem With Adobe Acrobat/Reader. Please exit Adobe Acrobat/Reader and try again." When you click OK to the error, the PDF opens outside of the browser.
    Reason
    When you use the Adobe Customization Wizard to create a transform for Adobe Acrobat 8 or Adobe Reader 8, and you choose the option to "Make Acrobat the default viewer if both Acrobat and Reader are installed", or "Make Reader the default viewer if both Acrobat and Reader are installed", an error occurs if the computer does not have Acrobat or Reader already installed.
    Solution
    Create a new transform and re-deploy Acrobat or Adobe Reader.
    Start the Adobe Customization Wizard 8.
    Open your previously created .mst file.
    Under Installation Options, select "Installer will decide which product will be the default".
    Save the transform.
    Re-deploy Acrobat or Adobe Reader.
    Additional Information
    When you create a transform in Adobe Customization Wizard 8, the installation options allow you to set the default viewer for PDF files. "Installer will decide which product will be the default" is the default setting and should be used when you are uncertain if the target machine has a version of Acrobat or Adobe Reader that won't be removed as part of the installation process. When installed silently using this option, Acrobat will always be configured as the default viewer.

    I think you are headed down the wrong path. The Customization Wizard is what you use to push out Reader to several hundred computers. An MST is a package or transform file that is used to accomplish this task. Unless you are an IT person and are trying a deployment of Reader this solution does not fit your situation.

  • HT3964 I just opened up my MacBook Pro after a few days of not using it and it was frozen. I turned it off and back on and all I see is a white screen, there was a file with a question mark flashing for a bit but I can't do anything, please help me!!

    I just opened up my MacBook Pro after a few days of not using it and it was frozen. I turned it off and back on and all I see is a white screen, there was a file with a question mark flashing for a bit but I can't do anything, please help me!!

    Jerricayoung,
    you have a 13-inch Mid 2012 MacBook Pro. It’s modern enough that it supports booting into Recovery mode. To do so, hold down a Command key and the R key as you start up. It should eventually show a Mac OS X Utilities menu. Select Disk Utility from that menu; when the Disk Utility window appears, select the bootable volume from the left-hand side of the window. (It’s typically called “Macintosh HD”.) When the volume is selected, some buttons will appear on the right-hand side. If it’s not greyed out, press the Verify Disk button; if it is greyed out, or if it reports on errors that it found, press the Repair Disk button. Once the verification/repair is completed, exit Disk Utility and select Restart from the Apple menu; that will restart your MacBook Pro in its normal mode. With luck, that will be enough to get you to your normal login screen, rather than the white screen.

  • Printing Error: There is a problem with a font file.

    I get this error when I try to print:
    "Printing Error: There is a problem with a font file."
    I tried exporting to PDF and printing from there. I get this message:
    "An error exist on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem."
    Has anyone encountered this problem?

    You may have a corrupted font. Try substituting fonts to see which one is the problem.

Maybe you are looking for

  • Client/Server to Web-Based application Conversion

    Hi! Everyone, I have couple of questions for you guys. Our Client had recently upgraded Forms 4.5 to 6i to move from Client/Server based application to Web based application. They are using Forms Server 6i Patch Set 1, OAS 4.0.8.1, Windows NT Service

  • How can I keep my regions organized for arranging in Logic 9?

    I just finished getting all of the loops/tracks I need for my dub tune, and it's time to arrange it.  My arrange view is full of scattered puzzle pieces.  The tracks and regions are named to help stay organized.  I start the tune on measure 16 so tha

  • Reg:File content conversion for Sender File Adaptor

    Hi all,             i would like to know , how the file content conversion is written for the below mentioned XML code. The flat file will have only the table name and the fieldname <?xml version="1.0" encoding="UTF-8"?> <ns0:Mt_File xmlns:ns0="http:

  • How to set the PATH Environment variable with multiple homes?

    I have several Oracle homes, and now I cannot get reports to work anymore. These are the things I installed, in this order: - Oracle Database 10g - Oracle Developer Suite 10g - Oracle Discoverer 4 - Oracle HTMLDB Now my PATH environment variable is f

  • XSD Files Externally defined - WEBLOGIC 8.1

    Hi, i have a problem, and i need your help.. I have been designing a service, that refers to a xsd file externally defined.. here are wsdl the example: <wsdl:definitions ..... <wsdl:types> <s:import namespace="http://empresa.com.ar/201006/01/AgentesS